Navigation: uCss > Source > Modules > Patterns > Button
Modules: Config | Base | Layout | Theming | Typography | Patterns | Utilities
The Universal Trigger. A highly configurable, interactive element pattern. Whether it's a link, a form submit, or a dashboard toggle, the
.btnclass handles it all with consistent sizing, states, and accessibility focus rings. It decouples implementation details (HTML tag) from user intent (Action).
The Button Pattern is likely the most used component in any UI. It is the primary mechanism for User Action.
.btn to <a>, <button>, <input type="submit">, or even <div> (though please use semantic tags).<svg> or .icn element placed inside a button is automatically sized to 1em and colored to match the text..btns wrapper automatically handles spacing (gap) and wrapping for collections of actions.[!LIGHTBULB] Did you know? You can combine any skin with any size and any shape.
.btn.primary.lg.pillworks just as well as.btn.outlined.sm.sq. The system is combinatorial.
In uCss, "Button-ness" is a set of visual and interactive traits:
We abstract these traits into the .btn class. This allows you to turn a standard Hyperlink (<a href>) into a Button visually, without breaking the semantic navigational meaning.
We separate Structure (base.css) from Skin (skins.css).
This separation allows you to create a "Ghost Button" just by changing the Skin variables (--btn-bg: transparent), without re-declaring padding or alignment logic.
<button class="btn">Default</button>.--p) styling..plain: <button class="btn plain">Action</button>..sm: <button class="btn sm">Secondary Action</button>.<div class="btns c">
<!-- Secondary Action -->
<button class="btn secondary">Cancel</button>
<!-- Primary Action -->
<button class="btn primary shadow-m">Save Changes</button>
</div>
This Submodule is part of patterns.css.
| File | Full (Raw) | Clean | Min | Gzip | Brotli |
|---|---|---|---|---|---|
button/base.css |
7.0 KB | 6.2 KB | 5.4 KB | 1.3 KB | 1.2 KB |
button/skins.css |
9.3 KB | 8.6 KB | 7.8 KB | 1.6 KB | 1.3 KB |
button/sizes.css |
2.4 KB | 2.0 KB | 1.7 KB | 0.5 KB | 0.5 KB |
button/group.css |
2.9 KB | 2.7 KB | 2.3 KB | 0.6 KB | 0.5 KB |
<link rel="preconnect" href="https://ucss.unqa.dev">
Since this is a nested module, it is included in patterns.min.css:
<link rel="stylesheet" href="https://ucss.unqa.dev/latest/lib/patterns.min.css">
The src/lib/patterns/button directory contains specific partials.
| File | Description | Download |
|---|---|---|
base.css |
Core. Defines the .btn class, reset properties, focus rings, and transition timings. |
src |
skins.css |
Colors. Defines modifier classes like .primary, .secondary, .outlined, .plain. |
src |
sizes.css |
Dimensions. Defines size modifiers like .sm, .lg and shape modifiers like .pill. |
src |
group.css |
Layout. Defines the .btns container for grouping buttons with gaps. |
src |
The Skin engine works by intercepting 3 variables:
--btn-bg: Background Color.--btn-c: Text/Icon Color.--btn-bc: Border Color (defaults to --btn-bg).The .primary Class:
.btn.primary {
--btn-bg: var(--p); /* Use Global Primary */
--btn-c: var(--on-p); /* Use Global Contrast */
/* Border color automatically matches bg */
}
The .outlined Class:
.btn.outlined {
--btn-bg: transparent;
--btn-bc: currentColor; /* Matches text */
/* It doesn't set color, so it inherits from context */
}
This is why you can combine them: <button class="btn primary outlined">.
Wait, primary sets color to white (usually). So .primary.outlined would be White Text on Transparent BG with White Border. Perfect for Dark backgrounds.
The Size engine manipulates:
--btn-fs: Font Size.--btn-pd: Padding (Inline and Block).--btn-h: Min-Height.| Size | Font Size | Padding |
|---|---|---|
.tiny |
0.625rem |
0.25em 0.5em |
.sm |
0.875rem |
0.375em 0.75em |
.md |
1rem |
0.5em 1em |
.lg |
1.25rem |
0.625em 1.25em |
Notice that padding uses em. This means if you manually override font-size, the padding scales proportionally automatically.
.btns)Never just put two buttons next to each other.
Wrap them in .btns.
var(--g-gap) space between them..btns.c centers them. .btns.e aligns to end..btns.c--sm centers ONLY on mobile (Layout shift pattern: Stacked centered buttons on mobile, Inline left buttons on desktop).If you add an <svg> or .icn inside a .btn:
--btn-c (text color).1.25em.Reversing order:
Add .rv (Reverse) to the button.
<button class="btn rv">
Next <svg>...</svg>
</button>
The Flexbox flex-direction flips, placing the icon to the right of the text.
Loading (.is-loading):
pointer-events: none.wait.Disabled (:disabled or .is-disabled):
opacity: 0.64.cursor: normal.| Class | Styles | Semantics |
|---|---|---|
.btn |
Inline-Flex, Center, Pointer, Default Styles. | The atom. |
.btn.full |
width: 100%. |
Full width button. |
.btn.is-loading |
Cursor Wait, Opacity reduced, Spinner. | Loading state. |
.btn:disabled |
Cursor Not-Allowed, Opacity reduced. | Disabled state. |
| Class | Description |
|---|---|
.primary |
Brand Color (--p). |
.secondary |
Dark / Gunmetal (--d). |
.tertiary |
Beige / Light (--l). |
.accent |
Brand Accent (--a). |
.success |
Green (--scs). |
.danger / .error |
Red (--alr). |
.outlined |
Transparent BG, Colored Border. |
.subtle |
Low contrast background (10% opacity). |
.plain |
No background, no border (Text Link style). |
.dark |
Force Dark Theme. |
.light |
Force Light Theme. |
| Class | Scale | Use Case |
|---|---|---|
.tiny |
0.625rem |
Table actions, tiny tags. |
.xsm |
0.75rem |
Meta tags. |
.sm |
0.875rem |
Dense UI, Toolbars. |
.md |
1rem |
(Default) Standard actions. |
.lg |
1.25rem |
Hero CTAs. |
.xlg |
1.375rem |
Massive landing page buttons. |
| Class | Effect |
|---|---|
.pill |
High Border Radius (Capsule). |
.sq |
Square Radius (0). |
.lt |
Light Radius. |
.bd |
Bold Radius. |
.rd |
Round Radius (Circle) - use with icons only. |
.btns)| Class | Description |
|---|---|
.btns |
Flex container with gap. |
.btns.c |
Center align (Justify Center). |
.btns.e |
End align (Justify End / Right). |
.btns.s |
Start align (Justify Start / Left). |
.btns.sb |
Space Between. |
.btns.rv |
Box Order Reverse (Right-to-Left visual). |
.btns.il |
Icon Left / Start (Icon on the left). |
.btns.ir |
Icon Right / End (Icon on the right). |
.btns.col |
Stack buttons vertically. |
<a>.<button>..btn class on either.uCss ensures they look identical, so you can choose the semantically correct tag without fighting standard browser styles.
<a href="/login" class="btn primary">Login Page</a>
<button onclick="login()" class="btn primary">Login Action</button>
outline unless you replace it..primary class automatically selects a high-contrast text color (--on-p) based on your config. If your Primary brand color is light yellow, ensure --on-p is dark.You can compose a FAB using only utilities:
<button class="btn primary rd shadow-xl abs p-m" style="bottom: 2rem; right: 2rem">
Add
</button>
If you need a marketing button that breaks the scale:
.btn.mega {
--btn-fs: 2.5rem;
--btn-pd: 2em 4em;
--btn-rad: 999px;
--btn-shadow: 0 10px 40px rgba(var(--p-rgb), 0.5);
font-weight: 900;
letter-spacing: -0.05em;
}
React/Vue Component:
const Button = ({ variant = 'primary', size = 'md', children, ...props }) => (
<button className={`btn ${variant} ${size}`} {...props}>
{children}
</button>
);
Navigation: uCss > Source > Modules > Patterns > Button
Modules: Config | Base | Layout | Theming | Typography | Patterns | Utilities
License: MPL-2.0 Copyright: Β© 2025 Shukhrat (Alive π) β€» UNQA
src/lib/
βββ config/ # 1. CONFIGURATION (The Brain)
β βββ root/ # - Semantic Modules
β β βββ colors.css # - Palettes & Themes
β β βββ typography.css # - Fonts & Scales
β β βββ layout.css # - Radius & Spacing
β β βββ patterns.css # - Component Vars
β βββ adapters/ # - CMS Adapters
β β βββ blocksy.css # - Blocksy Theme
β β βββ gutenberg.css # - WordPress Block Editor
β βββ root.css # - Entry Point
β
βββ base/ # 2. BASE (The Foundation)
β βββ html/ # - HTML Engine
β β βββ reset.css # - Normalization
β β βββ typography.css # - Text Defaults
β β βββ flow.css # - Smart Flow Engine
β β βββ lists.css # - List Styles
β β βββ forms.css # - Input Styling
β β βββ helpers.css # - HTML Utilities
β βββ html.css # - Entry Point
β
βββ patterns/ # 3. PATTERNS (The Components)
β βββ button/ # - Atomic Component <== YOU ARE HERE
β β βββ base.css
β β βββ group.css
β βββ card/ # - Card Component
β β βββ base.css
β β βββ content.css # - Slots & Padding
β β βββ media.css # - Full-bleed Media
β β βββ subgrid.css # - Subgrid Support
β βββ button.css # - Aggregator
β βββ card.css # - Aggregator
β βββ media.css # - Media Wrapper
β βββ link.css # - Link Wrapper
β βββ patterns.css # - Entry Point
β
βββ layout/ # 4. LAYOUT (The Skeleton)
β βββ grid/ # - Grid Engine
β β βββ base.css # - Core Logic
β β βββ columns.css # - Presets
β β βββ subgrid.css # - Smart Grid
β β βββ recipes.css # - Smart Logic (.masonry .g-row)
β β βββ item.css # - Child Logic
β βββ flex/ # - Flex Engine
β β βββ base.css # - Core Logic
β β βββ alignment.css # - Alignment Tools
β β βββ gaps.css # - Smart Gaps
β β βββ item.css # - Child Logic
β βββ container.css # - Container Queries (.c)
β βββ flex.css # - Entry Point
β βββ grid.css # - Entry Point
β βββ section.css # - Structural Layout
β
βββ theming/ # 5. THEMING (The Skin)
β βββ set.css
β βββ overlay.css
β
βββ typography/ # 6. TYPOGRAPHY (The Voice)
β βββ title.css
β βββ text.css
β βββ text-align.css
β
βββ utilities/ # 7. UTILITIES (The Tools)
βββ display.css
βββ position.css
βββ overflow.css
βββ margin.css
βββ padding.css
βββ radius.css
βββ size.css # - Size Utilities
βββ blur.css
βββ utilities.css