Box

The most fundamental layout component that renders a div by default and can be styled with any CSS classes. It serves as a building block for creating other components.

Anatomy

<script>
  import { Box } from "@saas-ui/svelte/layout/box";
</script>

<Box class="p-4 bg-gray-100 rounded">
  Content goes here
</Box>

Examples

As Prop Accessibility

Use the as prop to render Box as a different HTML element while maintaining all styling capabilities.

Basic Accessibility

Basic Box component with padding and background styling applied via classes.

Border Accessibility

Apply border styles using Tailwind border utilities for outlined containers.

Composition Accessibility

Compose Box with other components to create complex layouts and card-like structures.

Nested Accessibility

Nest multiple Box components to create layered layouts with different styling contexts.

Shadow Accessibility

Apply shadow effects using Tailwind shadow utilities for elevated appearance.

Shorthand Accessibility

Use Tailwind utility classes directly on Box for quick styling without creating custom components.

Props

Prop Type Default Description
as text div The HTML element to render.
children any - The content to be rendered inside the component.
class text - Additional CSS classes to apply.