@chakra-ui/react#Box JavaScript Examples
The following examples show how to use
@chakra-ui/react#Box.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Navbar.js From GitMarkonics with MIT License | 6 votes |
function NavHeader() {
return (
<Box className="nav_header" p={1}>
<Flex direction="row " >
<img src={logo} alt="heading" width="100px" className="logo"/>
<Spacer />
<Stack direction="row" spacing={2}>
<Link to="/">
<Button leftIcon={<GrHome />} colorScheme="pink" variant="solid" className="home">
Home
</Button>
</Link>
</Stack>
</Flex>
</Box>
);
}
Example #2
Source File: Card.js From codeursenseine.com with MIT License | 6 votes |
Card = forwardRef(({ isLink, variant, ...props }, ref) => {
const theme = useTheme();
const primary = {
background: theme.gradients.brand,
color: "white",
};
return (
<Box
ref={ref}
position="relative"
d="flex"
flexDirection="column"
p={6}
borderRadius="md"
boxShadow="brand"
border="1px solid transparent"
overflow="hidden"
_hover={
isLink
? {
borderColor: "brand.600",
cursor: "pointer",
}
: {}
}
_focus={
isLink
? {
borderColor: "brand.600",
}
: {}
}
{...(variant === "primary" ? primary : {})}
{...props}
/>
);
})
Example #3
Source File: Card.js From DAOInsure with MIT License | 6 votes |
function Card({ cardTitle, backgroundColor, children, isLoading }) {
return (
<VStack borderRadius="10px" borderStyle="solid" borderColor="whatsapp.500" borderWidth="1px" width="100%" alignItems="flex-start">
<Box backgroundColor={backgroundColor} width="100%" borderBottomWidth="1px" borderColor="whatsapp.500" px="20px" py="20px">
<Skeleton isLoaded={!isLoading}>
<Heading fontSize="16px">
{cardTitle}
</Heading>
</Skeleton>
</Box>
<VStack alignItems="flex-start" px="20px" py="20px" width="100%">
{children}
</VStack>
</VStack>
);
}
Example #4
Source File: Container.js From benjamincarlson.io with MIT License | 6 votes |
Container = ({ children }) => {
const router = useRouter()
return (
<>
<Link isExternal href="https://github.com/sponsors/bjcarlson42">
<Box bgGradient='linear(to-l, #7928CA, #FF0080)'>
<Flex justify="center" align="center" py={1} color="white">
<GitHubIcon />
<Text ml={2}>Sponsor Me On GitHub!</Text>
</Flex>
</Box>
</Link>
<Box h={8} bgColor={useColorModeValue("rgb(248, 250, 252)", "gray.900")} />
<Navigation />
<Box h={8} bgColor={useColorModeValue("rgb(248, 250, 252)", "gray.900")} />
<Flex
as="main"
justifyContent="center"
flexDirection="column"
bg={useColorModeValue("#ffffff", "#15161a")}
color={useColorModeValue("#000000", "#ffffff")}
>
{/* hero outside main Flex to avoid px */}
{router.pathname == '/' && <Hero />}
<Flex px={4} flexDir="column" minH="90vh">
{children}
</Flex>
<Footer />
</Flex>
</>
)
}
Example #5
Source File: App.js From react-sample-projects with MIT License | 6 votes |
function App() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Router hashType="slash">
<ChakraProvider theme={theme}>
<NavBar />
<Box
textAlign="center"
fontSize="xl"
height="calc(100vh - 64px)"
width="90%"
pt={16}
ml={'auto'}
mr={'auto'}
>
<Routes>
<Route exact path="/" element={<Home />}></Route>
<Route
exact
path="/product/add"
element={<ProductAddEdit />}
></Route>
<Route
exact
path="/product/:id"
element={<ProductDetails />}
></Route>
<Route exact path="/cart" element={<Cart />}></Route>
</Routes>
</Box>
</ChakraProvider>
</Router>
</PersistGate>
</Provider>
);
}
Example #6
Source File: _app.js From idena-web with MIT License | 6 votes |
function IdenaApp(props) {
const router = useRouter()
const id = useRef(uuidv4())
useEffect(() => {
ReactGA.initialize('UA-139651161-3')
ReactGA.pageview(window.location.pathname + window.location.search)
}, [])
useEffect(() => {
TagManager.initialize({gtmId: 'GTM-P4K5GX4'})
}, [])
useEffect(() => {
const handleRouteChange = url => {
ReactGA.pageview(url)
}
router.events.on('routeChangeComplete', handleRouteChange)
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
}, [router.events])
return ['/certificate/[id]', '/too-many-tabs'].includes(router.pathname) ? (
<QueryClientProvider client={queryClient}>
<Box {...props} />
</QueryClientProvider>
) : (
<AppProviders tabId={id.current} {...props} />
)
}
Example #7
Source File: nav-head.js From GitMarkonics with MIT License | 5 votes |
function NavHeader() { return ( < Box className = "nav_header" p = { 1 } > < Flex direction = "row " > < img src = { logo } alt = "heading" width = "80px" / > < Spacer / > < Stack direction = "row" spacing = { 2 } > < Link to = "/login" > < Button leftIcon = { < GrLogin / > } colorScheme = "pink" variant = "solid" > Login < /Button> < / Link > < Link to = "/register" > < Button colorScheme = "white" variant = "outline" > Register < /Button> < / Link > < Link to = "/contactus" > < Button leftIcon = { < GrLogin / > } colorScheme = "blue" variant = "solid" > ContactUs < /Button> < / Link > < /Stack> < / Flex > < /Box> ); } export default NavHeader;
Example #8
Source File: MeetupSpeaker.js From codeursenseine.com with MIT License | 5 votes |
MeetupSpeaker = ({ speaker, ...props }) => {
const md = new Remarkable("full", {
html: true,
});
// Save original method to invoke.
var originalRender = md.renderer.rules.link_open;
md.renderer.rules.link_open = function () {
// Invoke original method first.
let result = originalRender.apply(null, arguments);
result = result.replace(
">",
'target="_blank" rel="noopener noreferrer" class="remarkable-link">'
);
return result;
};
const bio = md.render(speaker.bio);
return (
<Stack spacing={2} {...props}>
<Heading as="h5" size="sm" color="brand.900">
{speaker.name}
</Heading>
<Stack isInline spacing={6}>
<Image
boxSize={{ base: "5rem", sm: "7.5rem" }}
flex="none"
objectFit="cover"
src={speaker.avatar}
alt={speaker.name}
fallbackSrc="/default.jpg"
borderRadius={4}
/>
<Stack>
<Box
className="remarkable"
dangerouslySetInnerHTML={{ __html: bio }}
/>
{speaker.twitter && (
<Text>
Twitter :{" "}
<A
href={`https://twitter.com/${speaker.twitter}`}
target="_blank"
>
@{speaker.twitter}
</A>
</Text>
)}
</Stack>
</Stack>
</Stack>
);
}
Example #9
Source File: App.js From DAOInsure with MIT License | 5 votes |
function App() {
const [isMember, setIsMember] = useState(false);
return (
<>
<Router>
<Header isMember={isMember} setIsMember={setIsMember} />
<Box pt='60px'>
<Switch>
{isMember ? (
<div>
<CustomRoute isMember={isMember} exact path='/'>
<ClaimsPage />
</CustomRoute>
<CustomRoute
isMember={isMember}
exact
path='/voting/:id'>
<VotingPage />
</CustomRoute>
<CustomRoute
isMember={isMember}
exact
path='/profile'>
<Profile />
</CustomRoute>
<CustomRoute
isMember={isMember}
exact
path='/makeclaim'>
<MakeClaim />
</CustomRoute>{" "}
<CustomRoute
isMember={isMember}
exact
path='/activity'>
<ActivityPage />
</CustomRoute>
</div>
) : (
<Route>
<BecomeMember />
</Route>
)}
</Switch>
</Box>
</Router>
</>
);
}
Example #10
Source File: App.js From interspace.chat with GNU General Public License v3.0 | 5 votes |
function App() {
const curURL = useRef(null);
let host = curURL ?? curURL.current;
useEffect(() => {
if (typeof window !== "undefined") {
const getHostname = () => {
if (typeof window !== "undefined") {
curURL.current = window.location.origin;
console.log(window.location);
// return host;
return null;
}
};
getHostname();
}
}, [curURL]);
// TODO: Need to give the option to turn off animations but not sure how to do it yet ?
// const [toggleAnim, setToggleAnim] = useState(false)
return (
<div
className="App"
>
<HeadComponent url={host} img={`${host}${SocialImg}`} />
<SiteHeader />
<Box
sx={{
scrollSnapType: { base: "y proximity", md: "unset" },
d: 'block',
position: "relative",
width: '100%',
height: 'auto',
overflowX: "hidden",
zIndex: 2,
m: 0,
p: 0,
section: {
scrollSnapAlign: { base: "start" },
scrollSnapStop: { base: "smooth" },
},
}}
>
{/* <Suspense fallback={<Loader />}> */}
<Canvas />
{/* </Suspense> */}
<HomeSection />
<ScheduleSection />
<WorkshopsSection />
<SpeakersSection />
<MetaverseSection />
<ChatSection />
<ApplySection />
<EasterEgg />
<AlphaNotice />
{/* TODO: Need to figure out how to stop the animations, in gsap & three's `tick()` */}
{/* <Button
position="fixed"
bottom={20}
left={6}
colorScheme="pink"
transition="all 0.3s 0.8s ease"
onClick={setToggleAnim}
zIndex={2002}
>
Turn off animations
</Button> */}
<SiteFooter />
</Box>
</div>
);
}
Example #11
Source File: GitHubSponsorCard.js From benjamincarlson.io with MIT License | 5 votes |
GitHubSponsorCard = () => {
const { colorMode } = useColorMode()
const colorSecondary = {
light: 'gray.600',
dark: 'gray.400'
}
return (
<Box
w="100%"
p={5}
my={4}
border='1px solid'
borderColor="lightgray"
borderRadius={5}
h="100%"
>
<Flex>
<Image w="75px" h="75px" borderRadius={5} src="/images/portrait.jpeg"></Image>
<Flex flexDirection={['column', 'row']}>
<Flex
width="100%"
align="flex-start"
justifyContent="space-between"
flexDirection="column"
mx={2}
>
<Heading as="h3" size="md">
Sponsor Benjamin Carlson on GitHub Sponsors
</Heading>
<Text color={colorSecondary[colorMode]}>
Hi ? I'm Benjamin Carlson, a senior college student studying computer science. I post weekly tutorial videos on my YouTube channel and build cool open source projects!
</Text>
</Flex>
<Flex mt={[2, 0, 0]}>
<iframe src="https://github.com/sponsors/bjcarlson42/button" title="Sponsor bjcarlson42" height="35" width="116" style={{ border: '0' }}></iframe>
</Flex>
</Flex>
</Flex>
</Box>
)
}
Example #12
Source File: Cart.js From react-sample-projects with MIT License | 5 votes |
Cart = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const cartItems = useSelector(state => state.cart.cartItems);
const viewProductDetails = (e, item) => {
navigate(`/product/${item.id}`);
};
const deleteItem = (e, item) => {
e.stopPropagation();
e.preventDefault();
dispatch(deleteItemFromCart(item));
};
if (cartItems.length === 0) {
return (
<Flex>
<Box
m={4}
w="100%"
fontWeight="semibold"
letterSpacing="wide"
textAlign="center"
>
You cart empty :(
</Box>
</Flex>
);
}
return (
<Box m={3} p={3}>
<Table variant="simple">
<Thead>
<Tr>
<Th>#</Th>
<Th>Image</Th>
<Th>Title</Th>
<Th isNumeric>Price</Th>
<Th isNumeric>Quantity</Th>
<Th>Action</Th>
</Tr>
</Thead>
<Tbody>
{cartItems.map((item, index) => (
<Tr key={item.id} onClick={e => viewProductDetails(e, item)}>
<Td>{index + 1}</Td>
<Td>
<Avatar size={'sm'} src={item.image} alt={item.title} />
</Td>
<Td>{item.title}</Td>
<Td isNumeric>
${parseFloat(item.price * item.quantity).toFixed(2)}
</Td>
<Td isNumeric>{item.quantity}</Td>
<Td>
<Button onClick={e => deleteItem(e, item)}>Delete</Button>
</Td>
</Tr>
))}
</Tbody>
</Table>
</Box>
);
}
Example #13
Source File: edit.js From idena-web with MIT License | 5 votes |
export default function EditAdPage() {
const {t} = useTranslation()
const router = useRouter()
const {data: ad} = usePersistedAd(router.query.id)
const coinbase = useCoinbase()
const adFormRef = React.useRef()
const previewAdRef = React.useRef()
const previewDisclosure = useDisclosure()
return (
<Layout showHamburger={false}>
<Page px={0} py={0} overflow="hidden">
<Box flex={1} w="full" px={20} py={6} overflowY="auto">
<PageHeader>
<PageTitle mb={0}>{t('Edit ad')}</PageTitle>
<PageCloseButton href="/adn/list" />
</PageHeader>
<AdForm
ref={adFormRef}
id="adForm"
ad={ad}
onSubmit={async nextAd => {
await db.table('ads').update(ad.id, nextAd)
router.push('/adn/list')
}}
/>
</Box>
<PageFooter>
<SecondaryButton
onClick={async () => {
const currentAd = Object.fromEntries(
new FormData(adFormRef.current).entries()
)
previewAdRef.current = {
...ad,
...currentAd,
author: ad.author ?? coinbase,
thumb: isValidImage(currentAd.thumb)
? URL.createObjectURL(currentAd.thumb)
: ad.thumb,
media: isValidImage(currentAd.media)
? URL.createObjectURL(currentAd.media)
: ad.media,
}
previewDisclosure.onOpen()
}}
>
<HStack>
<TriangleUpIcon boxSize="3" transform="rotate(90deg)" />
<Text>{t('Show preview')}</Text>
</HStack>
</SecondaryButton>
<PrimaryButton form="adForm" type="submit">
{t('Save')}
</PrimaryButton>
</PageFooter>
</Page>
<AdPreview ad={previewAdRef.current} {...previewDisclosure} />
</Layout>
)
}