Data displayContactInfo
Searchastronomic.dev# ContactInfo
For your email, phone, address and business hours as a short list of labeled details.
Static: no JavaScript.
## Usage
```astro
import ContactInfo from "@astronomic-dev/ui/components/ContactInfo.astro";
```
## Examples
### Every detail
The email, phone, address and hours, in that order, each a small muted label over its detail. Leave any of them out and its label goes too. ContactSplit and ContactDetails build their details from it, so you only need it for your own layout.
```astro
---
import ContactInfo from "@astronomic-dev/ui/components/ContactInfo.astro";
// Made-up details: a reserved .example address, and a US number from the 555-0100 to 555-0199 range kept for fiction.
const hours = [
{ label: "Mon to Thu", value: "9 a.m. to 5:30 p.m." },
{ label: "Fri", value: "9 a.m. to 3 p.m." },
];
---
<ContactInfo class="max-w-md" email="hello@astronomic.example" phone="+1 (312) 555-0147" address={["Astronomic", "12 Orbit Lane", "Example City, IL 60601"]} hours={hours} />
```
## Props
### ContactInfo
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `email` | `string` | None | Your email address, shown as a mailto: link. It breaks after the @ first, so a narrow column keeps the name whole; only a part too long for the column breaks inside it. |
| `phone` | `string` | None | Your phone number, shown as written, such as "+1 (312) 555-0147". The tel: link keeps only the digits and a leading + (tel:+13125550147). |
| `address` | `string[]` | `[]` | Your address, one line each, kept as lines in <address>. |
| `hours` | `ContactHours[]` | `[]` | Opening hours, one { label, value } per line (ContactHours), such as { label: "Mon to Fri", value: "9 a.m. to 5:30 p.m." }: the days and the times in two columns. |
| `emailLabel` | `string` | `"Email"` | The email's label. |
| `phoneLabel` | `string` | `"Phone"` | The phone's label. |
| `addressLabel` | `string` | `"Address"` | The address's label. |
| `hoursLabel` | `string` | `"Hours"` | The hours' label. |
| `itemClass` | `string` | None | For recipes. Classes for each label and its detail (the <div> round each <dt> and <dd>), such as a basis in a row that wraps. |
| `emailItemClass` | `string` | None | For recipes. Classes for the email's label and detail only, after itemClass, so they win: such as basis-full, to give the email a row of its own (ContactDetails). |
| `emailClass` | `string` | None | For recipes. Classes for the email link, such as a larger type role (ContactDetails). |
| `class` | `string` | None | More classes for the <dl>, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <dl>.
## Accessibility
- The details are a description list (<dl>): each label is its term, so a screen reader reads "Email, hello@astronomic.example". What you leave out leaves no term.
- The email is a mailto: link that reads the address. It breaks after the @, so it is never split in the middle of a name.
- The phone is a tel: link, shown as you write it; the link keeps only the digits and a leading +, so it dials from a phone.
- On touch screens the email and phone links are boxes of 44px at least.
- The address is in <address>, its lines kept. The hours are a list of their own: the days, then the times.
- The labels are props with plain English defaults: pass your page's own words in another language.
ContactInfo
FreeFor your email, phone, address and business hours as a short list of labeled details.
- File
- ContactInfo.astro
- Group
- Data display
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Every detail
The email, phone, address and hours, in that order, each a small muted label over its detail. Leave any of them out and its label goes too. ContactSplit and ContactDetails build their details from it, so you only need it for your own layout.
- Phone
- +1 (312) 555-0147
- Address
- Astronomic
12 Orbit Lane
Example City, IL 60601 - Hours
- Mon to Thu
- 9 a.m. to 5:30 p.m.
- Fri
- 9 a.m. to 3 p.m.
Force statemain.astro
examples/contactinfo/main.astro
---
import ContactInfo from "@astronomic-dev/ui/components/ContactInfo.astro";
// Made-up details: a reserved .example address, and a US number from the 555-0100 to 555-0199 range kept for fiction.
const hours = [
{ label: "Mon to Thu", value: "9 a.m. to 5:30 p.m." },
{ label: "Fri", value: "9 a.m. to 3 p.m." },
];
---
<ContactInfo class="max-w-md" email="hello@astronomic.example" phone="+1 (312) 555-0147" address={["Astronomic", "12 Orbit Lane", "Example City, IL 60601"]} hours={hours} />Minimal · Light