Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smashercosmo/636d63140e7cf777bf19db7f963c8cd5 to your computer and use it in GitHub Desktop.
Save smashercosmo/636d63140e7cf777bf19db7f963c8cd5 to your computer and use it in GitHub Desktop.
Any object wrapped in this component stops affecting line-height
.root {
display: inline-flex;
}
.object {
display: inline-grid;
grid-template-rows: 0;
align-items: center;
align-self: center;
}
.aligner {
visibility: hidden;
margin-left: -1ex;
}
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