Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript Error: Property 'above' does not exist on type 'ShowProps' in Chakra UI

I'm following a tutorial that uses Chakra UI, and the following code works perfectly in the tutorial. However, in my project, I get a TypeScript error on the above prop in the Show component:

import { Grid, GridItem, Show } from "@chakra-ui/react"


function App() {
  return <Grid templateAreas={{
    base: `"nav" "main"`,
    lg: `"nav nav" "aside main"`,
  }}>
    {/* some other components */}
    <Show above="lg">
        <GridItem area="aside" bg="gold">
            Aside
        </GridItem>
    </Show>
  </Grid>
}

export default App

the error message reads: Type '{ children: Element; above: string; }' is not assignable to type 'IntrinsicAttributes & ShowProps<unknown>'. Property 'above' does not exist on type 'IntrinsicAttributes & ShowProps<unknown>'

i use @chakra-ui/[email protected]

like image 701
Kun.tito Avatar asked Oct 30 '25 02:10

Kun.tito


2 Answers

Remove Show and add the "display" prop to the GridItem:

<GridItem area="aside" bg="gold" display={{ base: "none", lg: "block" }}>
    Aside
</GridItem>
like image 109
saff1x Avatar answered Nov 01 '25 18:11

saff1x


Based on document of chakra-ui above prop has been removed in version 3

if you want to use this props, you should install version 2 using

npm i @chakra-ui/[email protected]

you can see the documents for version 2 using chakra-ui-v2 docs

you can always install older versions of a package using this pattern

npm install <package>@<version>
like image 27
Eisa Rezaei Avatar answered Nov 01 '25 18:11

Eisa Rezaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!