28 CSS Input Fields18 / 28

Pure CSSMIT licensed

Time Range

Two <input type="time"> paired with a typographic `→` divider. Single visual unit while remaining two independent fields for keyboard nav and form submission.

Published

Live Demo
Try it

The code

<fieldset class="if-18">
  <legend class="if-18-legend">Quiet hours</legend>
  <span class="if-18-row">
    <label
      ><span class="if-18-cap">From</span><input type="time" name="from" value="22:00"
    /></label>
    <span class="if-18-sep" aria-hidden="true">→</span>
    <label><span class="if-18-cap">To</span><input type="time" name="to" value="07:00" /></label>
  </span>
</fieldset>
.if-18 {
  width: 100%;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  background: #1a1a22;
}

.if-18-legend {
  padding: 0 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #b8b6d4;
  text-transform: uppercase;
}

.if-18-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.if-18 label {
  flex: 1;
  display: grid;
  gap: 4px;
}

.if-18-cap {
  font-size: 10px;
  color: #b8b6d4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.if-18 input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #0c0c12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f0eeff;
  font: 600 13px/1 "JetBrains Mono", monospace;
  outline: none;
  color-scheme: dark;
}

.if-18 input:focus {
  border-color: #a78bfa;
}

.if-18-sep {
  color: #a78bfa;
  font-size: 14px;
  align-self: end;
  padding-bottom: 9px;
}
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS Input Field from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Time Range
Source: https://codefronts.com/components/css-input-fields/time-range/

Two <input type="time"> paired with a typographic `→` divider. Single visual unit while remaining two independent fields for keyboard nav and form submission.
## HTML
```html
<fieldset class="if-18">
  <legend class="if-18-legend">Quiet hours</legend>
  <span class="if-18-row">
    <label
      ><span class="if-18-cap">From</span><input type="time" name="from" value="22:00"
    /></label>
    <span class="if-18-sep" aria-hidden="true">→</span>
    <label><span class="if-18-cap">To</span><input type="time" name="to" value="07:00" /></label>
  </span>
</fieldset>
```
## CSS
```css
.if-18 {
  width: 100%;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  background: #1a1a22;
}

.if-18-legend {
  padding: 0 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #b8b6d4;
  text-transform: uppercase;
}

.if-18-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.if-18 label {
  flex: 1;
  display: grid;
  gap: 4px;
}

.if-18-cap {
  font-size: 10px;
  color: #b8b6d4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.if-18 input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #0c0c12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f0eeff;
  font: 600 13px/1 "JetBrains Mono", monospace;
  outline: none;
  color-scheme: dark;
}

.if-18 input:focus {
  border-color: #a78bfa;
}

.if-18-sep {
  color: #a78bfa;
  font-size: 14px;
  align-self: end;
  padding-bottom: 9px;
}
```

How this works

A time range picker with two input type="time" fields wrapped in a fieldset so screen readers announce them as one group. The row is a flex container with a decorative arrow separator between the From and To captions — each field stays independently keyboard-navigable and submits its own name.

color-scheme: dark flips the browser's time popover to a dark surface on Chromium and Firefox, so the AM/PM wheels don't flash white on click. This is the time range picker CSS pure pattern for quiet-hours settings, appointment windows, and shift scheduling — no JS, no date library, native validation on submit.

Make it yours

  • Retint the arrow separator and focus border to any brand accent via CSS custom properties.
  • Switch the legend copy ("Quiet hours") to Availability, Shift, or any window label.
  • Add step attribute (900 for 15-minute increments) to lock granularity.
  • Drop the fieldset border for a flatter, inline row inside a settings panel.

Gotchas — read before shipping

  • 12-hour vs 24-hour display follows the user's OS locale — you cannot force one from CSS or HTML.
  • The clock popover chrome differs across Chromium, Safari, and Firefox and can't be styled beyond color-scheme.
  • Cross-field validation (end after start) needs JS on submit — neither input knows about the other.

Browser support

ChromeSafariFirefoxEdge
20+14.1+57+20+

Time input is universal; only the dark-mode popover needs a modern engine.

Search CodeFronts

Loading…