import React from 'react'; import CenterH from '.'; import Block from '@techytools/ui/components/Block'; import CodeInline from '@techytools/ui/components/CodeInline'; import CanvasContainer from '@techytools/ui/.storybook/components/CanvasContainer'; import useShowStorybookCode from '@techytools/ui/hooks/useShowStorybookCode'; const Story = (props) => { useShowStorybookCode(); return (

More than just text-align:center...

Regular text-align:center can only center what fits inside it. If a line exceeds the width of the parent, it stops being centered, and overflows only to the right. This component makes text overflow to both left and right, evenly.

This title tag has white-space:nowrap, so it does not fit inside the column.

This can be used in a blog article, to render an extra-large image that sticks out evenly to left and right.

This could be useful if a button (or any element) has a max-width but the text is slightly too wide.

It could also be used in titles. When implementing responsive designs, you may put white-space:nowrap on a part of a title to force it to stay on one line.

The user/visitor browser/font settings, text may render a tiny bit wider than you tested and stick out to the right. This will make sure its always centered.

); }; export default Story; export const code = `import CenterH from '@techytools/ui/components/CenterChildrenX';

Normal text

This title tag has white-space:nowrap, so it's forced to stay on one line.

More normal text

`;