Size Context
Alignment target:@astryxdesign/core v0.7.1 · SizeContext
Usage #
SizeProvider sets a default size (sm, md, or lg) for a whole subtree. Interactive components inside use it when they have no size of their own; a component with an explicit size is unaffected. It renders no extra element and passes its default slot through.
import { provideSize, SizeProvider, useSize } from '@astryx-vue/core/SizeContext'Size resolves in this order, first match wins:
- The explicit
sizeon the component. Buttononly: the size of the enclosingButtonGroup.- The context from an enclosing
SizeProvideror container component. - The component's own default.
Toolbar, ButtonGroup, and InputGroup provide their size automatically, so children need no per-item size. Button, MoreMenu, TextInput, TextArea, Selector, MultiSelector, NumberInput, the date inputs and TimeInput, SegmentedControl, TabList, PowerSearch, and Tokenizer consume it.
Like other layer-scoped context, it resets inside teleported overlay layers: menus, popovers, and similar content rendered through a Teleport do not inherit the outer size. Add another SizeProvider inside the layer if needed.
Best practices #
| Guidance | Practices |
|---|---|
| Do | Set one size for a whole region with SizeProvider, or the size of Toolbar or InputGroup, instead of repeating it on every child. |
| Do | For a single exception, set size on that component; it always wins. |
| Don't | Expect SizeProvider to reach content inside overlay layers: teleported content falls back to defaults. |
Examples #
Common configurations, variations, and states.
Size Context — SizeContext — SizeProvider
The first row uses default sizes; the second is wrapped in SizeProvider value="sm", so the Button and TextInput both render small.