Component Library

← Back to gallery

Split team-contact profile header in HTML, CSS and vanilla JS

A copy-paste Split team-contact profile header in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Layout · Tags: profile-header, actions, layout

Live preview

Source (copy-ready)

<section class="dcl-profile-header-actions" data-dcl-scheme="light">
<header class="dcl-profile-header-actions-header"><div data-stack><div data-row><span data-panel aria-hidden="true">RG</span><h2>Rafi Green</h2></div>
<p>Studio coordinator for evening print sessions and open workshops.</p></div>
<nav aria-label="Contact options"><ul data-list><li><a href="#dcl-profile-header-actions-message" >Leave a message</a></li><li><a href="#dcl-profile-header-actions-work" >View portfolio</a></li><li><a href="#dcl-profile-header-actions-visit" >Studio hours</a></li></ul></nav></header><div data-stack><section id="dcl-profile-header-actions-message" data-panel tabindex="-1"><h3>Leave a message</h3><p>Leave a note with the workshop coordinator.</p></section><section id="dcl-profile-header-actions-work" data-panel tabindex="-1"><h3>View portfolio</h3><p>Recent series: Small towns at dusk.</p></section><section id="dcl-profile-header-actions-visit" data-panel tabindex="-1"><h3>Studio hours</h3><p>The studio is open Wednesdays from 14:00 to 18:00.</p></section></div>
<script>
(() => {
  const root = document.currentScript.parentElement;
  const instance = [...document.getElementsByClassName("dcl-profile-header-actions")].indexOf(root);
  if (instance > 0) {
    for (const node of root.querySelectorAll("[id], [for], [aria-labelledby], [aria-controls], [aria-describedby], a[href], input[name]")) {
      for (const key of ["id", "for", "aria-labelledby", "aria-controls", "aria-describedby", "name"]) {
        if (node.hasAttribute(key)) node.setAttribute(key, node.getAttribute(key).split(" ").map(value => value + "--" + instance).join(" "));
      }
      const href = node.getAttribute("href");
      if (href && href.startsWith("#")) node.setAttribute("href", href + "--" + instance);
    }
  }
  const scheme = matchMedia("(prefers-color-scheme: dark)");
  const applyScheme = () => { root.dataset.dclScheme = scheme.matches ? "dark" : "light"; };
  scheme.addEventListener("change", applyScheme);
  applyScheme();
  root.querySelectorAll('a[href^="#"]').forEach(link => {
    link.addEventListener("click", event => {
      if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
      const target = document.getElementById(link.getAttribute("href").slice(1));
      if (!target || !root.contains(target)) return;
      event.preventDefault();
      target.focus({preventScroll: true});
      target.scrollIntoView({block: "nearest"});
    });
  });
})();
</script>
</section>
<style>
.dcl-profile-header-actions { box-sizing: border-box; max-inline-size: 42rem; padding: clamp(.75rem, 4vw, 1.5rem); border: 1px solid; border-radius: .75rem; font: 1rem/1.5 system-ui, sans-serif; overflow-wrap: anywhere; }
.dcl-profile-header-actions *, .dcl-profile-header-actions *::before, .dcl-profile-header-actions *::after { box-sizing: border-box; }
.dcl-profile-header-actions h2, .dcl-profile-header-actions h3, .dcl-profile-header-actions p, .dcl-profile-header-actions ul, .dcl-profile-header-actions dl, .dcl-profile-header-actions figure { margin: 0; }
.dcl-profile-header-actions h2 { font-size: 1.25rem; line-height: 1.25; }
.dcl-profile-header-actions h3 { font-size: 1rem; }
.dcl-profile-header-actions > * + * { margin-block-start: .75rem; }
.dcl-profile-header-actions button, .dcl-profile-header-actions summary, .dcl-profile-header-actions input, .dcl-profile-header-actions select, .dcl-profile-header-actions textarea { font: inherit; }
.dcl-profile-header-actions button, .dcl-profile-header-actions summary { padding: .45rem .7rem; min-block-size: 2.75rem; border: 1px solid; border-radius: .375rem; cursor: pointer; text-align: start; }
.dcl-profile-header-actions select, .dcl-profile-header-actions input[type="text"], .dcl-profile-header-actions textarea { max-inline-size: 100%; padding: .45rem; border: 1px solid; border-radius: .375rem; }
.dcl-profile-header-actions button:active { transform: translateY(1px); }
.dcl-profile-header-actions button[disabled], .dcl-profile-header-actions button[aria-disabled="true"] { cursor: not-allowed; border-style: dashed; transform: none; }
.dcl-profile-header-actions button[aria-pressed="true"] { border-style: double; border-width: 3px; }
.dcl-profile-header-actions details > summary { inline-size: fit-content; }
.dcl-profile-header-actions [data-panel], .dcl-profile-header-actions dialog { border: 1px solid; border-radius: .625rem; padding: .8rem; }
.dcl-profile-header-actions dialog { max-inline-size: min(calc(100% - 2rem), 28rem); max-block-size: calc(100% - 2rem); }
.dcl-profile-header-actions dialog > * + * { margin-block-start: .75rem; }
.dcl-profile-header-actions [data-row] { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; min-inline-size: 0; }
.dcl-profile-header-actions [data-stack] { display: grid; gap: .6rem; min-inline-size: 0; }
.dcl-profile-header-actions [data-list] { list-style: none; padding: 0; display: grid; gap: .55rem; }
.dcl-profile-header-actions [data-wide] { flex: 1 1 11rem; min-inline-size: 0; }
.dcl-profile-header-actions .dcl-profile-header-actions-status { min-block-size: 1.5em; font-weight: 600; }
.dcl-profile-header-actions .dcl-profile-header-actions-glyph { display: inline-grid; place-items: center; font-size: 1.2em; line-height: 1; }
.dcl-profile-header-actions [hidden] { display: none; }
.dcl-profile-header-actions { color: #11292f; background-color: #ffffff; color-scheme: light; border-color: #697f84; }
.dcl-profile-header-actions a { color: #005c62; }
.dcl-profile-header-actions button, .dcl-profile-header-actions summary, .dcl-profile-header-actions input, .dcl-profile-header-actions select, .dcl-profile-header-actions textarea { color: #11292f; background-color: #e4edef; border-color: #697f84; }
.dcl-profile-header-actions .dcl-profile-header-actions-primary, .dcl-profile-header-actions button[aria-pressed="true"] { color: #ffffff; background-color: #00535a; }
.dcl-profile-header-actions button:hover, .dcl-profile-header-actions summary:hover { color: #ffffff; background-color: #00535a; }
.dcl-profile-header-actions button[disabled], .dcl-profile-header-actions button[aria-disabled="true"] { color: #405a60; background-color: #ffffff; }
.dcl-profile-header-actions [data-panel], .dcl-profile-header-actions dialog { color: #11292f; background-color: #e4edef; border-color: #697f84; }
.dcl-profile-header-actions :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; border-color: #839fa5; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] a { color: #8fe1da; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] button, .dcl-profile-header-actions[data-dcl-scheme="dark"] summary, .dcl-profile-header-actions[data-dcl-scheme="dark"] input, .dcl-profile-header-actions[data-dcl-scheme="dark"] select, .dcl-profile-header-actions[data-dcl-scheme="dark"] textarea { color: #eff8f9; background-color: #1c3c44; border-color: #839fa5; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] .dcl-profile-header-actions-primary, .dcl-profile-header-actions[data-dcl-scheme="dark"] button[aria-pressed="true"] { color: #11292f; background-color: #8fe1da; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] button:hover, .dcl-profile-header-actions[data-dcl-scheme="dark"] summary:hover { color: #11292f; background-color: #8fe1da; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] button[disabled], .dcl-profile-header-actions[data-dcl-scheme="dark"] button[aria-disabled="true"] { color: #b0c9ce; background-color: #142f36; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] [data-panel], .dcl-profile-header-actions[data-dcl-scheme="dark"] dialog { color: #eff8f9; background-color: #1c3c44; border-color: #839fa5; }
.dcl-profile-header-actions[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.dcl-profile-header-actions .dcl-profile-header-actions-header { display: grid; gap: 1rem; align-items: start; } .dcl-profile-header-actions nav a { display: block; padding: .4rem; border-block-end: 1px solid; } @media (min-width: 32rem) { .dcl-profile-header-actions .dcl-profile-header-actions-header { grid-template-columns: minmax(0, 2fr) minmax(10rem, 1fr); } }
</style>

When to use

Expose several equally useful contact routes next to the team member’s identity.

Avoid

Do not repeat links to the same destination or use a button to navigate.

Accessibility

Use descriptive native links in reading order and ensure visual rearrangement leaves their focus order intact. Light/dark body text: 15.19:1 and 13.07:1, respectively.

Was this useful? Send feedback.