HTML/CSS components Free template

Buttons, badges, alerts and cards

A small, copy-paste component set: button styles and sizes, badges, alerts and cards, all driven by CSS variables.

Live preview

The preview runs in a sandbox: it cannot reach your account, cookies or the network.

About this template

A tidy starter kit of everyday interface pieces: primary, secondary, outline and danger buttons in three sizes (with visible keyboard focus and a disabled state), badges, four kinds of alert and a card with an image area. Change the colours in the :root block at the top of style.css and every component follows. No JavaScript is needed.

buttonscardsalertscss variables

Look under the hood

Included source files

2,302 bytes
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>UI components</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main>
    <h1>Components</h1>

    <h2>Buttons</h2>
    <p class="row">
      <button class="btn">Primary</button>
      <button class="btn btn-secondary">Secondary</button>
      <button class="btn btn-outline">Outline</button>
      <button class="btn btn-danger">Delete</button>
      <button class="btn" disabled>Disabled</button>
    </p>
    <p class="row">
      <button class="btn btn-sm">Small</button>
      <button class="btn">Medium</button>
      <button class="btn btn-lg">Large</button>
    </p>

    <h2>Badges</h2>
    <p class="row">
      <span class="badge">New</span>
      <span class="badge badge-success">Active</span>
      <span class="badge badge-warning">Pending</span>
      <span class="badge badge-danger">Failed</span>
    </p>

    <h2>Alerts</h2>
    <div class="alert alert-info" role="status"><strong>Heads up.</strong> Your trial ends in 3 days.</div>
    <div class="alert alert-success" role="status"><strong>Saved.</strong> Your changes are live.</div>
    <div class="alert alert-warning" role="alert"><strong>Careful.</strong> This action cannot be undone.</div>
    <div class="alert alert-danger" role="alert"><strong>Error.</strong> We could not reach the server.</div>

    <h2>Cards</h2>
    <div class="cards">
      <article class="card">
        <div class="card-image" aria-hidden="true"></div>
        <div class="card-body">
          <span class="badge">Guide</span>
          <h3>Getting started</h3>
          <p>Learn the basics in ten minutes with a short, practical walk-through.</p>
          <a class="btn btn-outline btn-sm" href="#">Read more</a>
        </div>
      </article>
      <article class="card">
        <div class="card-image alt" aria-hidden="true"></div>
        <div class="card-body">
          <span class="badge badge-success">Popular</span>
          <h3>Build a portfolio</h3>
          <p>Create a personal site you can publish today, step by step.</p>
          <a class="btn btn-outline btn-sm" href="#">Read more</a>
        </div>
      </article>
    </div>
  </main>
</body>
</html>

Update history

  1. 1.0.0

    First release.