Skip to content

Cant use custom theme #302

Description

@spyshower

What happened?

I did what the docs say but I get error

Image

Steps to Reproduce

Add this in global.css:

`
@import 'tailwindcss';
@import 'uniwind';

@layer theme {
:root {
@variant basic {
--color-background: #000000;
--color-foreground: #ffffff;
--color-primary: #3b82f6;
--color-card: #1f2937;
--color-border: #374151;

        --color-p: rgb(10, 128, 129);
    }

    @variant light {
        --color-background: #000000;
        --color-foreground: #ffffff;
        --color-primary: #3b82f6;
        --color-card: #1f2937;
        --color-border: #374151;

        --color-p: rgb(10, 128, 129);
    }

    @variant dark {
        --color-background: #000000;
        --color-foreground: #ffffff;
        --color-primary: #3b82f6;
        --color-card: #1f2937;
        --color-border: #374151;

        --color-p: rgb(10, 128, 129);
    }
}

}
`

  1. Add this to metro:
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const { withSentryConfig } = require('@sentry/react-native/metro');
const { withUniwindConfig } = require('uniwind/metro');
/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('@react-native/metro-config').MetroConfig}
 */
const config = {};

module.exports = withUniwindConfig(
    withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config)),
    {
        cssEntryFile: './global.css',
        extraThemes: ['basic'], // Register your custom theme here
    },
);
  1. Use it:
    import { Uniwind } from 'uniwind';
    Uniwind.setTheme('basic');

  2. Crash

Snack or Repository Link

Uniwind version

1.2.4

React Native Version

0.83.1

Platforms

Android

Expo

No

Additional information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions