1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

皆様お馴染みのchakra-ui
fontsize="md"の記法をReact Nativeで再現したかったのでしました。

"本家"
"React Nativeで再現した方"

誤差はちょっとあると思います。

fontsize="md"記法を対応させるためにはライブラリのインストールが必要です。

yarn add @shopify/restyle react-native-responsive-fontsize
  • @shopify/restyle: fontsizeなど記述する為にいる
  • react-native-responsive-fontsize: フォントサイズを再現するために画面幅からパーセンテージで調節可能にするため

@shopify/restyleの導入は以下のリンクから。。
https://shopify.github.io/restyle/fundamentals/defining-your-theme/
https://shopify.github.io/restyle/fundamentals/components/predefined-components#text

テーマファイルにこれを追記します。

theme.ts
〜〜〜〜〜〜〜
"6xl": {
     fontSize: RFPercentage(7.5),
 },
 "5xl": {
     fontSize: RFPercentage(6),
 },
 "4xl": {
     fontSize: RFPercentage(4.5),
 },
 "3xl": {
     fontSize: RFPercentage(3.8),
 },
 "2xl": {
     fontSize: RFPercentage(3),
 },
 xl: {
     fontSize: RFPercentage(2.5),
 },
 lg: {
     fontSize: RFPercentage(2.2),
 },
 md: {
     fontSize: RFPercentage(2),
 },
 sm: {
     fontSize: RFPercentage(1.8),
 },
 xs: {
     fontSize: RFPercentage(1.5),
 }
〜〜〜〜〜〜〜〜

🎉

main.ts
<Text variant="xs" my="sm">
    (xs) In love with React & Next
</Text>
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?