Usage
The Theme component allows you to override the theme of all child components without modifying each one individually. It uses Vue's provide / inject mechanism under the hood, so the overrides apply at any depth.
Use the b24ui prop to pass an object where keys are component names (camelCase) and values are their slot class overrides:
Multiple
You can theme multiple component types at once by passing different keys in the b24ui prop.
Nested
Theme components can be nested. When nested, the innermost Theme's overrides take precedence for the components it wraps.
Priority
The b24ui prop on individual components always takes priority over the Theme component. This lets you override specific instances while still benefiting from the shared theme.
Deep
Because the Theme component uses Vue's provide / inject, the overrides are available to all descendant components regardless of how deeply nested they are.
MyButton is a custom component that renders a B24Button internally. The theme overrides still apply because they propagate through the entire component tree.Examples
With form components
Use the Theme component to apply consistent styling across a group of form components.
With prose components
You can theme prose (typography) components by nesting them under the prose key. This is useful when rendering Markdown content with a tighter or custom typographic scale.
Getting started
This is a paragraph with a tighter typographic scale applied through the Theme component.
- First item
- Second item
- Third item
The spacing and font sizes are smaller than the defaults, making it ideal for compact content areas.