Created
March 2, 2025 12:48
-
-
Save smashercosmo/636d63140e7cf777bf19db7f963c8cd5 to your computer and use it in GitHub Desktop.
Any object wrapped in this component stops affecting line-height
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .root { | |
| display: inline-flex; | |
| } | |
| .object { | |
| display: inline-grid; | |
| grid-template-rows: 0; | |
| align-items: center; | |
| align-self: center; | |
| } | |
| .aligner { | |
| visibility: hidden; | |
| margin-left: -1ex; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { type ReactNode } from "react"; | |
| import styles from "./NotAffectingLineHeightObject.module.css"; | |
| type Props = { | |
| children: ReactNode; | |
| }; | |
| export function NotAffectingLineHeightObject({ children }: Props) { | |
| return ( | |
| <span className={styles.root}> | |
| {/* this character makes is so that children are aligned to baseline by default */} | |
| <span className={styles.aligner} aria-hidden="true"> | |
| x | |
| </span> | |
| <span className={styles.object}>{children}</span> | |
| </span> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment