Skip to content
AliasCSS Logo
v1.5.6
Docs / Components and design systems

Components and design systems

The x- library is a set of ready-made components written in AliasCSS. Use it, restyle it with variables, or replace it with a design system of your own.

The x- library

Each x- class is a statement: a set of AliasCSS classes compiled together into the components layer. They use theme tokens, so they follow light and dark, and any utility class you add next to one overrides it.

New
<div class="d-flex flex-wrap-wrap aic g-8px">
<button class="x-button">Save</button>
<button class="x-button x-button-secondary">Cancel</button>
<button class="x-button x-button-ghost x-button-sm">More</button>
<span class="x-badge">New</span>
</div>
Generated CSS
.d-flex {
  display: flex;
}
.flex-wrap-wrap {
  flex-wrap: wrap;
}
.aic {
  align-items: center;
}
.g-8px {
  gap: 8px;
}
@layer base {
  .x-button {
    all: unset;
  }
}
@layer components {
  .x-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: var(--x-form-height, 40px);
    padding-inline: var(--x-button-padding, 16px);
    border-radius: var(--x-form-radius, 8px);
    border-width: 1px;
    border-style: solid;
    border-color: var(--x-button-border-color,transparent);
    background-color: var(--x-button-bg,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 51.9076% c h));
    color: var(--x-button-color,white);
    font-size: var(--x-button-font-size, 15px);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition-property: background-color , border-color , color , transform;
    transition-duration: 0.15s;
  }
  .x-button:enabled:hover {
    background-color: var(--x-button-hover-bg,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 46.9058% c h));
  }
  .x-button:enabled:active {
    transform: scale(0.98);
  }
  .x-button > svg {
    flex-shrink: 0;
  }
  .x-button:focus-visible {
    outline-style: solid;
    outline-width: 2px;
    outline-color: var(--x-form-accent-color,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 51.9076% c h));
    outline-offset: 2px;
  }
  .x-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .x-button[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }
}
.x-button-secondary {
  --x-button-bg: light-dark(#fcfcfd,#111113);
  --x-button-hover-bg: light-dark(#f0f0f3,#212225);
  --x-button-color: light-dark(#1c2024,#edeef0);
  --x-button-border-color: light-dark(#cdced6,#43484e);
}
.x-button-ghost {
  --x-button-bg: transparent;
  --x-button-hover-bg: light-dark(#f0f0f3,#212225);
  --x-button-color: light-dark(#1c2024,#edeef0);
  --x-button-border-color: transparent;
}
.x-button-sm {
  --x-form-height: 32px;
  --x-button-padding: 12px;
  --x-button-font-size: 14px;
}
@layer components {
  .x-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--x-badge-height, 22px);
    padding-inline: var(--x-badge-padding, 8px);
    box-sizing: border-box;
    border-radius: var(--x-badge-radius, 999px);
    font-size: var(--x-badge-font-size, 12px);
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    background-color: var(--x-badge-bg,light-dark(#f0f0f3,#212225));
    color: var(--x-badge-color,light-dark(#60646c,#b0b4ba));
    border-width: 1px;
    border-style: solid;
    border-color: var(--x-badge-border-color,light-dark(#d9d9e0,#363a3f));
  }
}

Usage this month

You've used 7 of 10 projects.

<article class="x-card xw-320px">
<div class="x-card-body">
  <h3 class="x-card-title">Usage this month</h3>
  <p class="x-card-description">You've used 7 of 10 projects.</p>
</div>
</article>
Generated CSS
@layer components {
  .x-card {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    background-color: var(--x-card-bg,light-dark(#fcfcfd,#111113));
    color: var(--x-card-color,light-dark(#1c2024,#edeef0));
    border-width: 1px;
    border-style: solid;
    border-color: var(--x-card-border-color,light-dark(#d9d9e0,#363a3f));
    border-radius: var(--x-card-radius, 12px);
    box-shadow: var(--x-card-shadow, none);
  }
}
.xw-320px {
  max-width: 320px;
}
@layer components {
  .x-card-body {
    padding: var(--x-card-padding, 20px);
    flex-grow: 1;
  }
  .x-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
  }
  .x-card-description {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--x-card-muted-color,light-dark(#60646c,#b0b4ba));
  }
}
Group Classes
Forms x-button (+ -secondary -ghost -danger -sm -lg -icon), x-input, x-textarea, x-select, x-checkbox, x-radio, x-switch, x-range, x-file, x-progress, x-field, x-label, x-hint, x-error-text
Surfaces x-card (+ -header -body -footer -title -description -elevated -flat -interactive), x-badge, x-alert, x-table (+ -striped -bordered -hover -compact -sticky)
Overlays x-dialog (native <dialog>), x-dropdown (native popover), x-accordion (<details>)
Navigation x-tab-list, x-tab, x-tab-panel, x-breadcrumb, x-pagination, x-menu
Feedback x-spinner, x-skeleton, x-avatar, x-avatar-group
Layout x-stack, x-cluster, x-center, x-grid, x-switcher, x-sidebar, x-cover, x-frame, x-reel
Grid x-row (+ -xs … -xl or any gap such as x-row-20px), x-col-1 … x-col-12, x-col, x-col-auto, x-col-240px, x-col-offset-1 … 11
Content x-prose, x-kbd, x-code, x-code-block, x-divider, x-arrow
Theme x-theme, x-theme-light, x-theme-dark

The text you’re reading is styled by x-prose.

Restyle with variables

Components read --x- variables with sensible fallbacks. Set one on the component, or on any parent to restyle everything inside:

<div class="d-flex g-8px --x-form-radius:999px">
<button class="x-button --x-button-bg:greenTheme9">Approve</button>
<button class="x-button x-button-secondary">Later</button>
</div>
Generated CSS
.d-flex {
  display: flex;
}
.g-8px {
  gap: 8px;
}
.--x-form-radius\:999px {
  --x-form-radius: 999px;
}
@layer base {
  .x-button {
    all: unset;
  }
}
@layer components {
  .x-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: var(--x-form-height, 40px);
    padding-inline: var(--x-button-padding, 16px);
    border-radius: var(--x-form-radius, 8px);
    border-width: 1px;
    border-style: solid;
    border-color: var(--x-button-border-color,transparent);
    background-color: var(--x-button-bg,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 51.9076% c h));
    color: var(--x-button-color,white);
    font-size: var(--x-button-font-size, 15px);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition-property: background-color , border-color , color , transform;
    transition-duration: 0.15s;
  }
  .x-button:enabled:hover {
    background-color: var(--x-button-hover-bg,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 46.9058% c h));
  }
  .x-button:enabled:active {
    transform: scale(0.98);
  }
  .x-button > svg {
    flex-shrink: 0;
  }
  .x-button:focus-visible {
    outline-style: solid;
    outline-width: 2px;
    outline-color: var(--x-form-accent-color,oklch(from var(--accentColor,oklch(1 .25049 284.23)) 51.9076% c h));
    outline-offset: 2px;
  }
  .x-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .x-button[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }
}
.--x-button-bg\:greenTheme9 {
  --x-button-bg: light-dark(#30a46c,#30a46c);
}
.x-button-secondary {
  --x-button-bg: light-dark(#fcfcfd,#111113);
  --x-button-hover-bg: light-dark(#f0f0f3,#212225);
  --x-button-color: light-dark(#1c2024,#edeef0);
  --x-button-border-color: light-dark(#cdced6,#43484e);
}

Because components live in the components layer, a plain utility always wins: class="x-button p-0-24px" changes only the padding.

12-column grid

x-row is a flex row with a gap, and x-col-N spans N of 12 columns. There are no negative margins, so a card can be the column itself. Give each breakpoint its own size (see the responsive rules):

<div class="x-row">
  <article class="x-card @xs-x-col-12 @sm-x-col-6 @lg-x-col-3">…</article>
</div>

Build your own design system

The x- library is an example, not a fixed API. Define your own classes in aliascss.config.js:

export default {
  extend: {
    'ui-btn': {
      type: 'statement',
      statement: `
        @base-all-unset
        @components[d-inline-flex,aic,g-8px,p-8px-16px,br-8px,bgc--ui-btn-bg:accentRA1000,c-white,cursor-pointer]
        @components--hover-bgc--ui-btn-hover:accentRA1100
        @components--focus-visible[outline-2px-solid-currentColor,outline-offset-2px]
      `,
    },
    'ui-reset': { type: 'raw', statement: `*{box-sizing:border-box}` },
  },
};
Type What it is
statement A class made of AliasCSS classes. Can span several lines and use scopes.
raw Plain CSS, output as written.
group A function that takes a value, like x-col-6 or x-row-24px.

By convention, custom classes get a short prefix (ui-, x-) so they never look like a property alias.