diff --git a/src/button/styles.ts b/src/button/styles.ts index f3f8c955..177866ca 100644 --- a/src/button/styles.ts +++ b/src/button/styles.ts @@ -19,7 +19,7 @@ export const buttonCSS = css` } &[disabled] { cursor: default; - opacity: ${theme.opacity.disabled}; + opacity: var(--ac-opacity-disabled); } &[data-size='default'][data-childless='false'] { padding: var(--ac-global-dimension-static-size-100) diff --git a/src/provider/GlobalStyles.tsx b/src/provider/GlobalStyles.tsx index e9851186..fa48ff7e 100644 --- a/src/provider/GlobalStyles.tsx +++ b/src/provider/GlobalStyles.tsx @@ -1016,6 +1016,10 @@ export const derivedCSS = (theme: ProviderTheme) => css` --ac-alias-single-line-width: var(--ac-global-dimension-size-2400); } `; + +const opacitiesCSS = css` + --ac-opacity-disabled: 0.6; +`; export function GlobalStyles() { let { theme } = useProvider(); theme = theme || 'dark'; @@ -1027,7 +1031,8 @@ export function GlobalStyles() { staticCSS, themeCSS, derivedCSS(theme), - mediumRootCSS + mediumRootCSS, + opacitiesCSS )} /> ); diff --git a/src/provider/Provider.tsx b/src/provider/Provider.tsx index 36800327..f04647a2 100644 --- a/src/provider/Provider.tsx +++ b/src/provider/Provider.tsx @@ -7,7 +7,12 @@ const Context = React.createContext(null); export function Provider(props: ProviderProps) { const prevContext = useContext(Context); - const { children, theme: propsTheme, ...context } = props; + const { + children, + theme: propsTheme, + mountGlobalStyles = true, + ...context + } = props; let theme: ProviderTheme = propsTheme || 'dark'; const isRootProvider = !prevContext; // If there is a theme higher up in the tree, use that theme @@ -21,7 +26,7 @@ export function Provider(props: ProviderProps) { ); return ( - {isRootProvider ? : null} + {isRootProvider && mountGlobalStyles ? : null}
{content}
); diff --git a/src/types/provider.ts b/src/types/provider.ts index dc96556c..9bf97218 100644 --- a/src/types/provider.ts +++ b/src/types/provider.ts @@ -16,6 +16,12 @@ interface ContextProps { export interface ProviderProps extends ContextProps { /** The content of the Provider. */ children: ReactNode; + /** + * Whether or not to mount the global styles. This should only be set to false if + * you are wanting to manually set the global design tokens. + * @default true + */ + mountGlobalStyles?: boolean; } -export type ProviderContext = ContextProps +export type ProviderContext = ContextProps;