Knit UI
GitHub

Playground

Loading playground…

false
false
Playground
<Spoiler
  showLabel="Show more"
  hideLabel="Hide"
  maxHeight={80}
  defaultExpanded={false}
  transitionDuration={200}
>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Spoiler>

Examples

No Overflow

Content that is shorter than maxHeight — the toggle is never rendered.

Loading example…

No OverflowSourceStorybook

With Overflow

Content that overflows and reveals the toggle control.

Loading example…

With OverflowSourceStorybook

Default Expanded

Starts fully expanded via defaultExpanded.

Loading example…

Default ExpandedSourceStorybook

Shadows

Elevation shadow ladder applied via the inherited shadow prop.

Loading example…

ShadowsSourceStorybook

Controlled

Controlled expanded state wired to external React state.

Loading example…

ControlledSourceStorybook

No Animation

Animation disabled — the region snaps to its target height instantly.

Loading example…

No AnimationSourceStorybook

Custom Labels

Custom show/hide labels with emoji to illustrate arbitrary ReactNode labels.

Loading example…

Custom LabelsSourceStorybook

Multiple Instances

Multiple independent Spoilers side by side, each with a different maxHeight.

Loading example…

Multiple InstancesSourceStorybook

Styles

Per-slot styles targets individual parts — here the region and control.

Loading example…

StylesSourceStorybook

Props

PropTypeDefaultDescription
hideLabel requiredReactNodeHideLabel on the control while the content is expanded.
showLabel requiredReactNodeShow moreLabel on the control while the content is collapsed.
childrenReactNodeLorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
controlRefRef<TamaguiElement> | undefinedRef of the toggle control element.
defaultExpandedboolean | undefinedfalseInitial expanded state (uncontrolled).
disabled systemboolean | undefined
expandedboolean | undefinedControlled expanded state.
hideAriaLabelstring | undefinedAccessible label for the toggle when expanded (falls back to `hideLabel`).
maxHeightnumber | undefined100Maximum height (px) of the collapsed region. The toggle appears only when the content exceeds this value.
onExpandedChange((expanded: boolean) => void) | undefinedCalled when the expanded state is toggled by the user.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
showAriaLabelstring | undefinedAccessible label for the toggle when collapsed (falls back to `showLabel`).
styles systemSlotStyles<SpoilerStyles> | undefinedUniform per-slot style passthrough — sugar over the composable parts. Slots: `root` / `region` / `control` / `fade`. Explicit inline props win.
theme systemThemeName | null | undefinedApplies a theme to this element
transitionDurationnumber | undefined200Height-animation duration in ms. Set to 0 to disable the animation entirely.

Style slots

Every part of Spoiler can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
controlstyles={{ control: { … } }}
fadestyles={{ fade: { … } }}
regionstyles={{ region: { … } }}
rootstyles={{ root: { … } }}
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 496 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.