diff --git a/apps/docs/content/docs/overview/styling.mdx b/apps/docs/content/docs/overview/styling.mdx index f2b34d6c..68cbcea2 100644 --- a/apps/docs/content/docs/overview/styling.mdx +++ b/apps/docs/content/docs/overview/styling.mdx @@ -1,20 +1,69 @@ --- title: Styling -description: Use Luke UI components, layout utilities, recipes, and semantic variables together. +description: + Choose component APIs, primitives, recipes, variables, or themes without overriding internals. --- -Luke UI ships static CSS. It does not inject styles at runtime and does not add a general `css` or -`sx` prop. Import the shared stylesheet and a theme stylesheet once, then use component props for +Luke UI ships static CSS. It does not inject styles at runtime. Import the shared stylesheet and a theme stylesheet once, then use component props for the variations each component supports. -## What you get +## Choose a styling approach + +Work from the most specific public API to the broadest one. + +1. Use a component's props for its supported appearance, size, state, and behaviour. +2. Use a documented primitive when you need a different component structure. +3. Build custom UI with public recipes and semantic variables when the component is not provided. +4. Author a custom theme when the product needs a different visual foundation everywhere. + +Do not override component recipe selectors or implementation-state attributes such as +`data-hovered`, `data-pressed`, or `data-focus-visible`. They are not supported styling hooks and +can change without a migration path. + +### Start with component props Components are intentionally opinionated. Their public props cover supported variants, states, and -behaviour. The active theme provides the semantic colours, typography, spacing, radii, and depth -that make those components work together. +behaviour, while the active theme provides the semantic colours, typography, spacing, radii, and +depth that make those components work together. + +```tsx +import { Button } from '@luke-ui/react/button'; + +; +``` + +### Compose from primitives + +Use a documented primitive when component props do not provide the structure you need. Primitives +keep the accessibility and visual contract for a component family while leaving its children and +composition to your application. + +```tsx +import { Button } from '@luke-ui/react/button/primitive'; + +; +``` + +### Build custom UI with public recipes and variables + +Recipes from `@luke-ui/react/recipes` are public, component-specific styling APIs. Use one when a +custom composition follows that recipe's documented element contract. Do not copy or target its +generated selectors. + +```tsx +import { button } from '@luke-ui/react/recipes'; + +; +``` -Luke UI also exports the public `vars` token contract. Use it for a custom element that needs to -belong to the active theme. +The public `vars` token contract lets an application-owned element follow the active theme. ```tsx import { vars } from '@luke-ui/react/theme'; @@ -30,16 +79,32 @@ import { vars } from '@luke-ui/react/theme'; ``` The token contract is public. Component selectors, generated palette values, and theme -implementation details are not. +implementation details are not. See the [token reference](/theming/token-reference) for the full +contract. -## Override components carefully +### Change the visual foundation with a custom theme -Start with the component API. If the required presentation is outside that API, compose a custom -component from the relevant primitives and public variables rather than overriding internal -selectors. This keeps a component reliable when its recipe changes. +Use a [custom theme](/theming/authoring) when a product needs a different identity, typeface, or +semantic colour system. `buildTheme` produces a static stylesheet for the full semantic contract. It +is not a per-component override tool. -Recipes from `@luke-ui/react/recipes` are available for custom compositions. They are -component-specific, so use them only when you are building on that component's documented structure. +## Set up static styles + +Import `@luke-ui/react/stylesheet.css` and one bundled theme stylesheet at the application entry +point. Apply `themeRootClassName` and the matching identity class to the same application or subtree +root. The reset is scoped to that root, so it does not reset unrelated application content. + +```tsx +import '@luke-ui/react/stylesheet.css'; +import '@luke-ui/react/themes/tactile.css'; +import { themeRootClassName } from '@luke-ui/react/theme'; +import { tactileThemeClassName } from '@luke-ui/react/themes'; +import { cx } from '@luke-ui/react/utils'; + +