Shadows

Design tokens for shadows and elevation

Shadows

Shadow tokens create depth and hierarchy in your interface through consistent elevation levels.

Shadow Scale

nonetokens.shadows.none
none shadow
No shadow
smtokens.shadows.sm
sm shadow
0px 1px 2px 0px rgba(0, 0, 0, 0.08)
mdtokens.shadows.md
md shadow
0px 1px 2px -2px rgba(0, 0, 0, 0.1), 0px 2px 3px -1px rgba(0, 0, 0, 0.2)
lgtokens.shadows.lg
lg shadow
0px 2px 4px -4px rgba(0, 0, 0, 0.3), 0px 6px 12px -3px rgba(0, 0, 0, 0.4)

Elevation Hierarchy

Use shadows to create visual layers and establish content hierarchy:

Ground Level

No elevation
Base content, backgrounds

Low Elevation

Small shadow
Cards, buttons

Medium Elevation

Medium shadow
Dropdowns, popovers

High Elevation

Large shadow
Modals, drawers

Component Examples

Interactive States

Button States

Card Variants

Outlined Card
Border only
Elevated Card
Subtle shadow
Floating Card
Prominent shadow

Usage

In CSS

.card {
  box-shadow: var(--token-shadows-sm);
}

.dropdown {
  box-shadow: var(--token-shadows-md);
}

.modal {
  box-shadow: var(--token-shadows-lg);
}

/* Hover effects */
.button:hover {
  box-shadow: var(--token-shadows-sm);
}

In JavaScript/TypeScript

import { tokens } from '@vibrant-ui/tokens';

// Convert shadow tokens to CSS
const getShadowCSS = (shadowToken: keyof typeof tokens.shadows) => {
  return tokens.shadows[shadowToken]
    .map(
      ({ offsetX, offsetY, blur, spread, transparency }) =>
        `${offsetX}px ${offsetY}px ${blur}px ${spread}px rgba(0, 0, 0, ${transparency})`,
    )
    .join(', ');
};

const cardStyle = {
  boxShadow: getShadowCSS('sm'),
};

With Vibrant UI Components

import { Card, Button, Modal } from '@vibrant-ui/components';

<Card shadow="sm">
  Card content
</Card>

<Button shadow="none">
  Flat button
</Button>

<Modal shadow="lg">
  Modal content
</Modal>

Guidelines

Elevation Levels

Use consistent elevation for similar components:

  • none: Flush with background, no elevation
  • sm: Subtle elevation for cards and buttons
  • md: Medium elevation for dropdowns and tooltips
  • lg: High elevation for modals and major overlays

Interaction States

Enhance interactivity with shadow transitions:

  • Rest: Base shadow or no shadow
  • Hover: Increase shadow for elevation feedback
  • Active: Reduce or invert shadow for pressed effect
  • Focus: Add colored shadow for accessibility

Performance

Optimize shadow rendering:

  • Use CSS custom properties for consistency
  • Avoid animating complex shadows frequently
  • Consider reduced motion preferences
  • Test on lower-end devices

Dark Mode

Shadows may need adjustment in dark themes:

  • Reduce shadow opacity
  • Consider using lighter shadows or borders
  • Maintain relative elevation hierarchy
Edit on GitHub

Last updated on