GitHub npm Toggle Layout

Solid Buttons

Filled background with high contrast text

Primary Secondary Danger Warning Info Success Disabled Loading

Outlined Buttons

Transparent background with colored border, fills with subtle color on hover

Primary Secondary Danger Warning Info Success

Ghost Buttons

No border or background initially, shows subtle background on hover

Primary Secondary Danger Warning Info Success

Link Buttons

Text-only styling, changes color on hover like a link

Primary Secondary Danger Warning Info Success

Full Width

Full Width Button

Code Usage

Copy and paste the following code to use buttons in your project

<!-- Solid Button -->
<base-button variant="solid-primary">Primary</base-button>
<base-button variant="solid-secondary">Secondary</base-button>
<base-button variant="solid-danger">Danger</base-button>

<!-- Outlined Button -->
<base-button variant="outlined-primary">Primary</base-button>

<!-- Ghost Button -->
<base-button variant="ghost-primary">Primary</base-button>

<!-- Link Button -->
<base-button variant="link-primary">Primary</base-button>

<!-- With States -->
<base-button variant="solid-primary" disabled>Disabled</base-button>
<base-button variant="solid-primary" loading>Loading</base-button>

<!-- Sizes -->
<base-button variant="solid-primary" size="sm">Small</base-button>
<base-button variant="solid-primary" size="md">Medium</base-button>
<base-button variant="solid-primary" size="lg">Large</base-button>

<!-- Full Width -->
<base-button variant="solid-primary" full-width>Full Width</base-button>

Inputs

Code Usage

Copy and paste the following code to use inputs in your project

<!-- Basic Input -->
<base-input
  label="Email"
  type="email"
  placeholder="Enter your email"
  size="md"
></base-input>

<!-- With Value -->
<base-input
  label="Website"
  type="url"
  value="https://example.com"
  size="md"
></base-input>

<!-- Required Field -->
<base-input
  label="Password"
  type="password"
  placeholder="Enter your password"
  required
  size="md"
></base-input>

<!-- With Hint -->
<base-input
  label="Phone"
  type="tel"
  placeholder="+1 (555) 000-0000"
  hint="We'll never share your phone number"
  size="md"
></base-input>

<!-- Error State -->
<base-input
  label="Username"
  type="text"
  error="This field is required"
  size="md"
></base-input>

<!-- Disabled -->
<base-input
  label="Disabled"
  type="text"
  value="Cannot edit this"
  disabled
  size="md"
></base-input>

Selects

Code Usage

Copy and paste the following code to use selects in your project

<!-- Basic Select -->
<base-select
  id="select-country"
  label="Country"
  placeholder="Select a country"
  size="md"
></base-select>

<!-- Searchable Select -->
<base-select
  id="select-searchable"
  label="Searchable Select"
  placeholder="Search for a fruit..."
  searchable
  size="md"
></base-select>

<!-- Required Field -->
<base-select
  id="select-required"
  label="Required Field"
  placeholder="Choose an option"
  required
  size="md"
></base-select>

<!-- With Hint -->
<base-select
  id="select-hint"
  label="With Hint"
  placeholder="Select a priority"
  hint="Choose the urgency level"
  size="md"
></base-select>

<!-- Error State -->
<base-select
  id="select-error"
  label="Error State"
  placeholder="Select an option"
  error="This field is required"
  size="md"
></base-select>

<!-- Disabled -->
<base-select
  id="select-disabled"
  label="Disabled"
  placeholder="Cannot select"
  disabled
  size="md"
></base-select>

Textareas

Code Usage

Copy and paste the following code to use textareas in your project

<!-- Basic Textarea -->
<base-textarea
  label="Description"
  placeholder="Enter a description..."
  size="md"
  rows="4"
></base-textarea>

<!-- With Hint -->
<base-textarea
  label="Comments"
  placeholder="Add your comments here..."
  hint="Maximum 500 characters"
  maxlength="500"
  size="md"
  rows="4"
></base-textarea>

<!-- Required Field -->
<base-textarea
  label="Required Field"
  placeholder="This field is required"
  required
  size="md"
  rows="4"
></base-textarea>

<!-- Error State -->
<base-textarea
  label="Error State"
  error="This field cannot be empty"
  size="md"
  rows="4"
></base-textarea>

<!-- Disabled -->
<base-textarea
  label="Disabled"
  value="This content cannot be edited"
  disabled
  size="md"
  rows="4"
></base-textarea>

<!-- Resizable -->
<base-textarea
  label="Both Resize"
  placeholder="Resize both ways"
  resize="both"
  size="md"
  rows="4"
></base-textarea>

Quantity Selects

Extra Small (xs)

Current value: 0

Small (sm)

Current value: 1

Medium (md) - Default

Current value: 5

Large (lg)

Current value: 10

Limited Range (0-10)

Current value: 5

Input Read-Only (buttons only)

Current value: 3

Code Usage

Copy and paste the following code to use quantity selects in your project

<!-- Basic Quantity Select -->
<quantity-select
  id="quantity-basic"
  value="0"
  min="0"
  max="99"
  size="md"
></quantity-select>

<!-- With Default Value -->
<quantity-select
  id="quantity-default"
  value="5"
  min="0"
  max="99"
  size="md"
></quantity-select>

<!-- Limited Range -->
<quantity-select
  id="quantity-limited"
  value="5"
  min="0"
  max="10"
  size="md"
></quantity-select>

<!-- Different Sizes -->
<quantity-select value="0" min="0" max="99" size="xs"></quantity-select>
<quantity-select value="0" min="0" max="99" size="sm"></quantity-select>
<quantity-select value="0" min="0" max="99" size="md"></quantity-select>
<quantity-select value="0" min="0" max="99" size="lg"></quantity-select>

<!-- Listening to Changes -->
<script>
const quantitySelect = document.getElementById('quantity-basic');
quantitySelect.addEventListener('quantity-change', (e) => {
  console.log('New quantity:', e.detail.value);
});
</script>

Drawers

Click buttons to open drawers. Drag down or click overlay to close.

Small Drawer Medium Drawer Large Drawer Drawer with Form

Code Usage

Copy and paste the following code to use drawers in your project

<!-- Button to Open Drawer -->
<base-button variant="solid-primary" onclick="document.getElementById('my-drawer').open()">
  Open Drawer
</base-button>

<!-- Drawer Component -->
<base-drawer id="my-drawer" size="md">
  <div style="padding: var(--space-4);">
    <h2>Drawer Title</h2>
    <p>Drawer content goes here</p>
    <base-button
      variant="solid-primary"
      onclick="document.getElementById('my-drawer').close()"
    >
      Close
    </base-button>
  </div>
</base-drawer>

<!-- Different Sizes -->
<base-drawer size="sm"></base-drawer> <!-- 320px -->
<base-drawer size="md"></base-drawer> <!-- 480px -->
<base-drawer size="lg"></base-drawer> <!-- 640px -->

<!-- Using JavaScript -->
<script>
const drawer = document.getElementById('my-drawer');

// Open drawer
drawer.open();

// Close drawer
drawer.close();

// Listen to events
drawer.addEventListener('drawer-open', () => {
  console.log('Drawer opened');
});

drawer.addEventListener('drawer-close', () => {
  console.log('Drawer closed');
});
</script>

Tabs

You're clicking on them

Code Usage

Copy and paste the following code to use tabs in your project

<!-- Basic Tabs -->
<base-tabs variant="horizontal" aria-label="Example tabs">
  <base-tab id="tab1" label="Tab 1">
    <p>Content for tab 1</p>
  </base-tab>

  <base-tab id="tab2" label="Tab 2">
    <p>Content for tab 2</p>
  </base-tab>

  <base-tab id="tab3" label="Tab 3">
    <p>Content for tab 3</p>
  </base-tab>
</base-tabs>

<!-- Tabs with Icons -->
<base-tabs variant="horizontal">
  <base-tab
    id="home"
    label="Home"
    icon='<svg viewBox="0 0 24 24"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>'
  >
    <p>Home content</p>
  </base-tab>
</base-tabs>

<!-- Sidebar Variant -->
<base-tabs variant="sidebar">
  <base-tab id="settings" label="Settings">
    <p>Settings content</p>
  </base-tab>
</base-tabs>

<!-- Programmatic Control -->
<script>
const tabs = document.querySelector('base-tabs');

// Switch to specific tab
tabs.switchTab('tab2');

// Listen for tab changes
tabs.addEventListener('tab-change', (e) => {
  console.log('Active tab:', e.detail.activeTab);
});
</script>

Date Pickers

Time Pickers

DateTime Pickers

Code Usage

Copy and paste the following code to use date and time pickers in your project

<!-- Date Picker -->
<base-date-picker
  id="date-picker"
  label="Select Date"
  placeholder="Choose a date"
  size="md"
></base-date-picker>

<!-- Time Picker (12-hour) -->
<base-time-picker
  id="time-picker-12"
  label="Select Time"
  placeholder="Choose a time"
  format="12"
  size="md"
></base-time-picker>

<!-- Time Picker (24-hour) -->
<base-time-picker
  id="time-picker-24"
  label="Select Time"
  placeholder="Choose a time"
  format="24"
  size="md"
></base-time-picker>

<!-- DateTime Picker -->
<base-datetime-picker
  id="datetime-picker"
  label="Select Date and Time"
  placeholder="Choose date and time"
  format="12"
  size="md"
></base-datetime-picker>

<!-- With Hints and Required -->
<base-date-picker
  label="Appointment Date"
  placeholder="Select appointment date"
  hint="Choose your preferred date"
  required
  size="md"
></base-date-picker>

<!-- Get Values -->
<script>
const datePicker = document.getElementById('date-picker');
const timePicker = document.getElementById('time-picker-12');
const dateTimePicker = document.getElementById('datetime-picker');

// Get selected values
console.log('Date:', datePicker.value);
console.log('Time:', timePicker.value);
console.log('DateTime:', dateTimePicker.value);

// Listen for changes
datePicker.addEventListener('change', (e) => {
  console.log('Date changed:', e.target.value);
});
</script>

Auth Controls

This likely wont be useful for anyone but I wanted it published for my own projects

Open Drawer Logout Refresh Tokens

Code Usage

Copy and paste the following code to use auth components in your project

<!-- Auth Form in Drawer -->
<base-drawer id="auth-drawer" size="sm">
  <auth-form
    id="auth-form"
    logo-url="https://example.com/logo.svg"
    api-domain="https://api.example.com"
    oauth-domain="https://auth.example.com"
    oauth-region="us-east-1"
    oauth-user-pool-id="us-east-1_XXXXXXXXX"
    oauth-client-id="your-client-id"
    oauth-spa-domain="https://oauth.example.com/"
  ></auth-form>
</base-drawer>

<!-- Button to Open Auth Drawer -->
<base-button
  variant="solid-primary"
  onclick="document.getElementById('auth-drawer').open()"
>
  Login
</base-button>

<!-- Auth Methods -->
<script>
const authForm = document.getElementById('auth-form');

// Handle authentication events
authForm.addEventListener('auth-success', (e) => {
  console.log('User authenticated:', e.detail);
  console.log('Access token:', e.detail.accessToken);
  console.log('ID token:', e.detail.idToken);
  console.log('Refresh token:', e.detail.refreshToken);
});

authForm.addEventListener('auth-error', (e) => {
  console.error('Auth error:', e.detail);
});

// Logout
authForm.logout();

// Refresh tokens
authForm.refreshTokens();

// Get current tokens
const tokens = authForm.getTokens();
</script>

Cards

Default Card

No border or shadow. Clean and minimal appearance.

Elevated Card

Has border and shadow for depth and separation.

Padding Variants

No Padding

Perfect for custom layouts or full-width content.

Small Padding

Compact spacing (var(--space-4))

Medium Padding

Default spacing (var(--space-6))

Large Padding

Generous spacing (var(--space-8))

Interactive Cards

Hoverable Card

Try hovering over me! The shadow increases on hover.

Click Me

Expandable Card

Hover to see the expand button appear in the top-right corner.

Complex Card Example

Product Card

Demonstrates a card with custom internal structure

$99.99 In Stock

This card uses padding="none" to create custom sections with individual padding and borders.

Add to Cart

Code Usage

Copy and paste the following code to use cards in your project

<!-- Basic Card -->
<base-card variant="default" padding="md">
  <h4>Card Title</h4>
  <p>Card content goes here</p>
</base-card>

<!-- Elevated Card -->
<base-card variant="elevated" padding="md">
  <h4>Elevated Card</h4>
  <p>Has border and shadow</p>
</base-card>

<!-- Padding Variants -->
<base-card variant="elevated" padding="none"></base-card>
<base-card variant="elevated" padding="sm"></base-card>
<base-card variant="elevated" padding="md"></base-card>
<base-card variant="elevated" padding="lg"></base-card>

<!-- Hoverable Card -->
<base-card variant="elevated" padding="md" hoverable>
  <h4>Hoverable Card</h4>
  <p>Hover effect on mouse over</p>
</base-card>

<!-- Expandable Card -->
<base-card variant="elevated" padding="md" expandable>
  <h4>Expandable Card</h4>
  <p>Can be expanded on hover</p>
</base-card>

<!-- Card with Custom Layout -->
<base-card variant="elevated" padding="none">
  <div style="padding: var(--space-6); border-bottom: 1px solid var(--color-border);">
    <h4>Header Section</h4>
  </div>
  <div style="padding: var(--space-6);">
    <p>Content section</p>
    <base-button variant="solid-primary">Action</base-button>
  </div>
</base-card>

Small Drawer

This is a small drawer (320px wide on desktop). Perfect for quick actions or notifications.

Close Drawer

Medium Drawer

This is a medium drawer (480px wide on desktop). Good for forms and detailed content.

Close Cancel

Large Drawer

This is a large drawer (640px wide on desktop). Ideal for complex forms or multi-step processes.

Example Content

Large drawers can contain extensive content like:

  • Multi-step wizards
  • Detailed forms
  • Rich media content
  • Settings panels
Got it!

Contact Form

Send Message Cancel