Contact: methods and hours
A set of contact methods with optional links, supporting details and icons.
pnpm dlx shadcn@latest add @haze/contact-methods---
import { Clock3, Mail, MapPin } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface Props {
id?: string;
eyebrow?: string;
title?: string;
description?: string;
headingLevel?: 1 | 2 | 3;
methods?: { icon: "email" | "location" | "hours"; label: string; value: string; detail: string; href?: string }[];
class?: string;
}
const icons = { email: Mail, location: MapPin, hours: Clock3 };
const {
id = "contact-methods",
eyebrow = "Contact",
title = "Find the right way to reach us",
description = "These example details show how to share a few helpful ways to get in touch.",
headingLevel = 2,
methods = [
{ icon: "email", label: "Email", value: "hello@example.com", detail: "For general questions and ideas." },
{ icon: "location", label: "Visit", value: "12 Market Street", detail: "Example address, Northport." },
{ icon: "hours", label: "Hours", value: "Monday to Friday", detail: "9:00 am–5:00 pm, local time." },
],
class: className,
} = Astro.props;
const Heading = ({ 1: "h1", 2: "h2", 3: "h3" } as const)[headingLevel];
const ItemHeading = ({ 1: "h2", 2: "h3", 3: "h4" } as const)[headingLevel];
---
<section aria-labelledby={`${id}-title`} class={cn("bg-background px-6 py-20 sm:py-24", className)}>
<div class="mx-auto max-w-6xl">
<div class="max-w-2xl">
<p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">{eyebrow}</p>
<Heading id={`${id}-title`} class="mt-3 text-3xl/9 font-semibold tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</Heading>
<p class="mt-4 text-base/7 text-pretty text-muted-foreground">{description}</p>
</div>
<ul class="mt-12 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{methods.map((method) => {
const Icon = icons[method.icon];
return <li class="rounded-xl border border-border bg-card p-6">
<span class="flex size-10 items-center justify-center rounded-lg bg-foreground/5 text-foreground inset-ring inset-ring-frame"><Icon aria-hidden="true" class="size-5" /></span>
<ItemHeading class="mt-6 text-sm/5 font-medium text-muted-foreground">{method.label}</ItemHeading>
<p class="mt-2 text-base/6 font-semibold tracking-tight text-foreground">{method.href ? <a href={method.href} class="rounded-sm underline underline-offset-4 transition-colors duration-150 ease-snappy hover:text-foreground/80 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">{method.value}</a> : method.value}</p>
<p class="mt-2 text-sm/6 text-muted-foreground">{method.detail}</p>
</li>;
})}
</ul>
</div>
</section>When to use
- Visitors need several ways to reach an organization
- Contact details and availability matter more than an on-page form
When not to use
- Visitors should submit a message directly; use contact-split-form
Installation
Add the Haze registry to components.json once, then install Contact: methods and hours with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/contact-methodsnpx shadcn@latest add @haze/contact-methodsyarn dlx shadcn@latest add @haze/contact-methodsbunx --bun shadcn@latest add @haze/contact-methodsFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "contact-methods" | Unique section ID prefix. |
| eyebrow | string | "Contact" | Label above the heading. |
| title | string | demo heading | Contact section heading. |
| description | string | demo copy | Introductory copy; the default marks the contact details as examples. |
| headingLevel | 1 | 2 | 3 | 2 | Section heading level; method titles use the next level. |
| methods | { icon: "email" | "location" | "hours"; label: string; value: string; detail: string; href?: string }[] | 3 example methods | Contact details and optional destinations; replace the fictional examples. |
| class | string | – | Additional section classes. |
Keyboard interactions
- Tab, Enter
- Open any contact links provided by the caller.
Accessibility
- Each contact method has a text heading and value; icons are decorative.
- A value is linked only when its destination is supplied.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Contact: methods and hours" with `npx shadcn@latest add @haze/contact-methods`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ContactMethods from "@/components/haze/blocks/contact-methods.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/contact-methods.md
Customize with real content
Adapt the Haze contact-methods block for our product. Replace the demo values of these props with our real content: id, eyebrow, title, description, headingLevel, methods, class. Keep the layout, the heading level rules and these accessibility details: Each contact method has a text heading and value; icons are decorative. A value is linked only when its destination is supplied. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using contact-methods, check it fits: use it when visitors need several ways to reach an organization; contact details and availability matter more than an on-page form. Avoid it when visitors should submit a message directly; use contact-split-form. Alternatives: @haze/contact-split-form.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.