Theme

Start Here

Start from the smallest working snippet, then move to interactive examples and the full API contract below.

Styled quick start

Copy this entrypoint first. It includes the imports required to get the component on screen.

svelte
<script lang="ts">
  import '@dryui/ui/themes/default.css';
  import '@dryui/ui/themes/dark.css';
  import { FocusTrap } from '@dryui/ui';
</script>

<FocusTrap>Content</FocusTrap>

Import options

Root package

ts
import { FocusTrap } from '@dryui/ui'

Per-component subpath

ts
import { FocusTrap } from '@dryui/ui/focus-trap'

Customize

Use the interactive examples to see common variants, states, and composition patterns before building your own.

Trap Focus in a Region

Focus trap is inactive.

svelte
<script lang="ts">
  let trapActive = $state(false);
</script>

<Button onclick={() => trapActive = true}>Activate Focus Trap</Button>

<FocusTrap active={trapActive} returnFocus>
  <div class="trap-container">
    <p>Focus is trapped inside this box while the trap is active.</p>
    <input placeholder="First field" />
    <input placeholder="Second field" />
    <Button onclick={() => trapActive = false}>Release Focus</Button>
  </div>
</FocusTrap>

Compose

The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.

Prop Type Default Required Bindable
active
boolean
initialFocus
string
returnFocus
boolean
children
Snippet

Forwards <div> attributes via rest props. Common examples: id, style, role.