8000 Column widths based on rem · TanStack table · Discussion #5460 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Column widths based on rem #5460

Answered by hex2r
PrettyCoffee asked this question in Q&A
Apr 2, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

@PrettyCoffee Here is the simple function you can use:

export default function convertPxToRems(px: number): string {
  const basicFontSize = parseFloat(
    getComputedStyle(document.querySelector("html")!).fontSize
  ) || 16;
  return `${px / basicFontSize}rem`;
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@PrettyCoffee
Comment options

@hex2r
Comment options

@hex2r
Comment options

Answer selected by PrettyCoffee
@PrettyCoffee
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
0