Components Buttons

Neo Press Button

A raised button with a solid offset shadow. Its face sinks into the shadow as you press and springs back on release.

Live previewGo + HTML

Usage

Set Label to describe the action. Supply Href for navigation or use Type to submit or reset a form. Name and Value identify a submit action in the form data. Set Disabled to make the control unavailable. The press effect runs in CSS and respects reduced-motion preferences.

Register neo-press-button with Head and pass its properties to Render. Go setup guide

Set Shape to rounded (default), pill, or sharp. Size sets the label size from 14 to 44 pixels (default 32). The padding and icon scale with it. Supply a hex color such as #ffffff for Color.

Icon accepts plus (default), arrow, check, star, heart, download, send, cart, play, mail, external, or sparkle. Use none for a text-only button.

Go usage
Go usage
err := mono.UI.Render(w, "neo-press-button", mono.Props{
	"Color": "#ffffff",
	"Icon":  "plus",
	"Label": "Press me",
	"Shape": "rounded",
	"Size":  32,
})
Rendered HTML
Rendered HTML
<button id="demo-neo-press-button" class="mu-neo" data-mono="neo-press-button"
  data-neo-shape="rounded"
  data-neo-icon="plus" style="--neo-face:#ffffff;--neo-ink:#141414;--neo-size:32px;"
  type="button"><span class="mu-neo-face">
  <span class="mu-neo-label">Press me</span>
  <svg data-neo-symbol viewBox="0 0 24 24" width="24" height="24" fill="none"
    stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"
    aria-hidden="true" focusable="false"><path d="M12 5v14M5 12h14"/></svg>
</span></button>
Submit a form
Submit a form
// Render inside a form with a POST action.
err := mono.UI.Render(w, "neo-press-button", mono.Props{
	"Label": "Save changes",
	"Type":  "submit",
	"Name":  "intent",
	"Value": "save",
	"Shape": "pill",
	"Size":  18,
	"Icon":  "check",
})
Go template
Go template
{{- define "neo-press-attrs" -}}
id="{{.ID}}" class="mu-neo" data-mono="neo-press-button"
  data-neo-shape="{{if eq (print .Shape) "pill" "sharp"}}{{.Shape}}{{else}}rounded{{end}}"
  data-neo-icon="{{or .Icon "plus"}}"{{with neoPressStyle .}} style="{{.}}"{{end}}
{{- end -}}

{{- define "neo-press-content" -}}
<span class="mu-neo-face">
  <span class="mu-neo-label">{{or .Label "Press me"}}</span>
  <svg data-neo-symbol viewBox="0 0 24 24" width="24" height="24" fill="none"
    stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"
    aria-hidden="true" focusable="false"><path d="{{neoPressPath .Icon}}"/></svg>
</span>
{{- end -}}

{{- if and .Href (not .Disabled) -}}
<a {{template "neo-press-attrs" .}} href="{{.Href}}">{{template "neo-press-content" .}}</a>
{{- else -}}
<button {{template "neo-press-attrs" .}}
  type="{{if eq (print .Type) "submit" "reset"}}{{.Type}}{{else}}button{{end}}"
  {{- with .Name}} name="{{.}}"{{end}}
  {{- if ne .Value nil}} value="{{.Value}}"{{end}}
  {{- if .Disabled}} disabled{{end}}>{{template "neo-press-content" .}}</button>
{{- end -}}
Component CSS
Component CSS
.mu-neo[data-mono] {
  --neo-depth: .7em;
  --neo-radius: .8em;
  --neo-edge: #141414;
  box-sizing: border-box;
  position: relative;
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr);
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0 var(--neo-depth) var(--neo-depth) 0;
  border: 0;
  appearance: none;
  background: transparent;
  color: var(--neo-ink, #141414);
  font: 700 clamp(14px, var(--neo-size, 32px), 44px)/1.1 Inter, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -.025em;
  text-decoration: none;
  text-align: center;
  vertical-align: middle;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.mu-neo[data-neo-shape="pill"] { --neo-radius: 999px; }
.mu-neo[data-neo-shape="sharp"] { --neo-radius: .2em; }
.mu-neo::before {
  content: "";
  position: absolute;
  inset: var(--neo-depth) 0 0 var(--neo-depth);
  border-radius: var(--neo-radius);
  background: var(--neo-edge);
}
.mu-neo-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7em;
  min-width: 0;
  padding: .7em 1.3em;
  background: var(--neo-face, #fafafa);
  border: .14em solid var(--neo-edge);
  border-radius: var(--neo-radius);
}
.mu-neo-label { min-width: 0; overflow-wrap: anywhere; }
.mu-neo [data-neo-symbol] { display: block; width: 1.1em; height: 1.1em; flex: none; }
.mu-neo[data-neo-icon="none"] [data-neo-symbol] { display: none; }
.mu-neo:focus-visible { outline: 3px solid #141414; outline-offset: 3px; box-shadow: 0 0 0 3px #fff; }
.mu-neo:disabled { opacity: .5; cursor: not-allowed; }

/* The backing and the pointer target stay fixed while the face moves. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .mu-neo:not(:disabled):hover .mu-neo-face { transform: translate(.28em, .28em); }
  .mu-neo:not(:disabled):hover [data-neo-symbol] { transform: var(--neo-gesture, rotate(45deg) scale(1.08)); }
  .mu-neo[data-neo-icon="arrow"] { --neo-gesture: translateX(5px); }
  .mu-neo[data-neo-icon="check"] { --neo-gesture: scale(1.15); }
  .mu-neo[data-neo-icon="star"] { --neo-gesture: rotate(72deg) scale(1.15); }
  .mu-neo[data-neo-icon="heart"] { --neo-gesture: scale(1.25); }
  .mu-neo[data-neo-icon="download"] { --neo-gesture: translateY(4px); }
  .mu-neo[data-neo-icon="send"], .mu-neo[data-neo-icon="external"] { --neo-gesture: translate(3px, -3px); }
  .mu-neo[data-neo-icon="cart"] { --neo-gesture: translateX(4px); }
  .mu-neo[data-neo-icon="play"] { --neo-gesture: translateX(3px) scale(1.1); }
  .mu-neo[data-neo-icon="mail"] { --neo-gesture: rotate(-8deg) scale(1.12); }
  .mu-neo[data-neo-icon="sparkle"] { --neo-gesture: rotate(90deg); }
}
.mu-neo:not(:disabled):active .mu-neo-face { transform: translate(var(--neo-depth), var(--neo-depth)); }
@media (prefers-reduced-motion: no-preference) {
  .mu-neo:not(:disabled):active [data-neo-symbol] { transform: scale(.92); }
  .mu-neo-face, .mu-neo [data-neo-symbol] {
    transition: transform 320ms cubic-bezier(.16, 1.45, .36, 1);
  }
  .mu-neo:not(:disabled):active .mu-neo-face,
  .mu-neo:not(:disabled):active [data-neo-symbol] {
    transition-duration: 80ms;
    transition-timing-function: ease-out;
  }
}
@media (forced-colors: active) {
  .mu-neo:focus-visible { outline-color: Highlight; }
  .mu-neo::before { background: ButtonText; forced-color-adjust: none; }
  .mu-neo .mu-neo-face { border-color: ButtonText; background: ButtonFace; color: ButtonText; }
  .mu-neo:disabled .mu-neo-face { color: GrayText; border-color: GrayText; }
}
Use the HTML in a static site

Copy the rendered HTML above. Download these assets into the same folder as your page, then add the tags below to its head.

Shared CSS Component CSS

HTML head
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./neo-press-button.css">

Copy into your project

Run this command from the Mono checkout. Set -out to the component directory in your application.

Terminal
go run ./cmd/mono-ui add -out ./components neo-press-button
Example properties (JSON)
example.json
{
  "Color": "#ffffff",
  "Icon": "plus",
  "Label": "Press me",
  "Shape": "rounded",
  "Size": 32
}