TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Underline Draw

A line draws into view to highlight a text link.

Live Demo

Hover over the element or press Tab to focus.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<button type="button" class="tb-tip tb-tip--underline">View details</button>
CSS
/* このサンプル共通のボタン基本形(単体利用可) */
.tb-tip {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  min-width: 156px;
  min-height: 52px;
  padding: 13px 21px;
  position: relative;
  border: 1px solid #c8d2e2;
  border-radius: 7px;
  background: #fff;
  color: #15233b;
  font: 650 14px/1.35 system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}
.tb-tip:focus-visible {
  outline: 3px solid #7864ed;
  outline-offset: 4px;
}

.tb-tip--underline { border-color: transparent; }
.tb-tip--underline::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 8px;
  height: 2px;
  background: #6350d9;
  transform: scaleX(0);
  transition: transform .29s ease;
}
.tb-tip--underline:is(:hover, :focus-visible, .is-active)::after {
  transform: scaleX(1);
}

@media (prefers-reduced-motion: reduce) {
  .tb-tip, .tb-tip::before, .tb-tip::after,
  .tb-tip > span { transition-duration: .01ms !important;
    animation-duration: .01ms !important; }
}

How to Use

Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.

Use Case

Navigation and in-content links.

Technical Notes

Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.

Mobile:Verify focus and tap behavior on touch devices.

Browser:Uses modern CSS features.

Reduced Motion:Respects prefers-reduced-motion.