Making React-Bootstrap Card body align horizontally instead of vertically - javascript

I have a React-Bootstrap Card component that I'm making. I'd like the content in the <Card.Body> to flow from left to right, similar to an HStack in SwiftUI. Currently, the content renders vertically. Is there any way to change this? Below is my code.
function TestCard(props) {
return (
<Card>
<Card.Img />
<Card.Body>
<Card.Title className="fw-bold">Card Title</Card.Title>
<div className="vr" />
<Card.Text>Card Text</Card.Text>
</Card.Body>
</Card>
);
}

Related

Slick Carousel removing bootstrap cards equal heights

I'm trying to do a products carousel with Slick and Bootstrap, but slick is removing Bootstrap nature of equalling heights as you can see in the screenshots:
https://imgur.com/QuzSIys ( without slick )
https://imgur.com/9P3sIJO ( with slick carousel )
Already tried a solution with JQuery and calcs but didn't work as expected, as shown in the next screenshots. ( I'm talking about this solution: Equal Height Bootstrap Cards within Slick Carousel )
https://imgur.com/RnlTaJr ( The height is so long and not in the bigger content max )
CAROUSEL CODE:
<Container className={'mt-2 mb-3'}>
<h3>{props.category}</h3>
<Row>
<Slider {...carouselSettings}>
{
products.map((product)=>{
return(
<Col className="col text-center">
<ProductCard title={product.title} description={product.description} image={product.image} />
</Col>
)
})
}
</Slider>
</Row>
</Container>
CARD COMPONENT CODE:
<Card className={'mh-100 h-100'}>
<div className={'wrapper'}>
<Card.Img className="img-fluid mh-100" variant="top" src={props.image} />
</div>
<Card.Body >
<Card.Title>{props.title}</Card.Title>
<Card.Text>
{props.description}
</Card.Text>
<Button variant="outline-primary" style={{marginRight: '10px'}}>Ver Mais</Button>
<Button variant="outline-success">Carrinho</Button>
</Card.Body>
</Card>
HOME CODE:
<>
<Header/>
<div className={'container mt-2'} style={{minHeight: 'calc(100vh - 380px)'}}>
<OffersCarousel/>
<ProductsCarousel category={'Lançamentos'}/>
</div>
<Footer/>
</>
Please any suggestion or fix to this or something that is not clear on this question tell me!

How to import and export methods and libraries defined in one js file to the other js file in react project

My problem is, I have a js file having a functionality of opening a tab-bar on clicking. Here is the link of that js file https://jsfiddle.net/6719phr3/1/
I want the same feature of opening a tab-bar to be used in the other js file as well without adding the methods and functionalities again in that js file. The Code is here.
import React, { useState,useCallback } from "react";
import {Card,CardGroup,Badge} from 'react-bootstrap';
const Health_status = (props) => {
return (
<CardGroup>
<Card className="cards">
<Card.Body>
<Card.Title>Cluster-1 [ID]</Card.Title>
<Card.Text>
</Card.Text>
</Card.Body>
<Card border="secondary" style={{ width: '18rem' }} className ="sub-cards-rec">
<Card.Header>Recording Unit [ID]</Card.Header>
<Card.Body>
<Card.Title>[ID]</Card.Title>
<Card.Text>
<h6 onClick{()=>openPane()}><Badge pill bg="primary" >Cumulative Data Rate:{}</Badge></h6>
{css ? (<h6 onClick={toggle2}><Badge pill bg="success" >Cumulative Sensor Status:{}</Badge></h6>)
:(<h6 onClick={toggle2}><Badge pill bg="danger" >Cumulative Sensor Status:{}</Badge></h6>)
}
</Card.Text>
</Card.Body>
</Card><br />
<Card border="secondary" style={{ width: '18rem' }} className ="sub-cards-ana">
<Card.Header>Analysis Unit [ID]</Card.Header>
<Card.Body>
<Card.Title>[ID]</Card.Title>
<Card.Text>
<h6><Badge pill bg="warning" >Instance-Number:{}</Badge></h6>
</Card.Text>
</Card.Body>
</Card><br />
</Card>
</CardGroup>
}
export default Health_status;
So I want to add a tabbar on clicking <Card.Text> Cumulative Data Rate from the above given code. How to export and import the methods and libraries from the first js file to this js file.

How to align elements in bootstrap cards to bottom of card?

In the CodeSandbox example below, I have two Bootstrap (reactstrap) Card elements side-by-side. Is there any way to get the Button in each card to align to the bottom of the card, plus some margin, so they look aligned to each other? I tried various Flexbox classes from the Bootstrap docs: https://getbootstrap.com/docs/4.0/utilities/flex/ but nothing has worked.
Note, the CodeSandbox output window has to be wide enough for the cards to stack side-by-side as in the image below.
CodeSandbox
below code content:
import React from "react";
import ReactDOM from "react-dom";
import {
Card,
CardText,
CardBody,
CardTitle,
CardSubtitle,
CardDeck,
Button
} from "reactstrap";
function App() {
return (
<div className="App">
<CardDeck>
<Card>
<CardBody>
<CardTitle tag="h5">Card title</CardTitle>
<CardSubtitle tag="h6" className="mb-2 text-muted">
Card subtitle
</CardSubtitle>
<CardText>
Some quick example text to build on the card title and make up the
bulk of the card's content.
</CardText>
<Button>Button</Button>
</CardBody>
</Card>
<Card>
<CardBody>
<CardTitle tag="h5">Card title</CardTitle>
<CardSubtitle tag="h6" className="mb-2 text-muted">
Card subtitle
</CardSubtitle>
<CardText>
Some quick example text to build on the card title and make up the
bulk of the card's content. Some quick example text to build on
the card title and make up the bulk of the card's content.
</CardText>
<Button>Button</Button>
</CardBody>
</Card>
</CardDeck>
</div>
);
}
you can use display flex. but you need to break your CardBody into two divs, one with the content, and another with the button. use then justifyContent: 'space-between'. Add also some margin-top to wrapping button div to ensure some space for safety.
below the approach I described:
<Card>
<CardBody style={{display: 'flex', flexDirection: 'column', justifyContent: 'space-between'}}>
<div>
<CardTitle tag="h5">Card title</CardTitle>
<CardSubtitle tag="h6" className="mb-2 text-muted">
Card subtitle
</CardSubtitle>
<CardText>
Some quick example text to build on the card title and make up the
bulk of the card's content.
</CardText>
</div>
<div style={{marginTop: '12px'}}>
<Button >Button</Button>
</div>
</CardBody>
</Card>

How to use antd divider to separate two sides of the screen in a react component?

I am using antd and would like the vertical divider to split the two sides of my screen. The two sides are in fact separated by different Col components. They currently look something like this:
class Example extends React.Component {
render () {
return (
<Row>
<Col span={11}>
CONTENT ONE SIDE
</Col>
<Col span={2}>
<Divider type='vertical'/>
</Col>
<Col span={11}>
CONTENT OTHER SIDE
</Col>
</Row>
)
}
}
The issue here is that the Divider is barely appearing. I would like it to go all the way down where the content ends. Instead, it is just a tiny little line.
This is a screenshot of what it currently looks like:
You can barely see the divider in the middle.
How can I make the vertical divider be as long as the content?
Thanks!
You can set the height of the divider to 100% , see this sandbox
<Divider type="vertical" style={{ height: "100%" }} />
Mine doesn't work with the above answers.
After a little bit of work. I finally got this below code to work.
< Divider
type="vertical" style={{ height: "100px", backgroundColor: "#000" }}
/>
height 100%
<Row>
<Col span={11}>
CONTENT ONE SIDE
<br />
CONTENT ONE SIDE
<br />
CONTENT ONE SIDE
<br />
</Col>
<Col span={2}>
<Divider type="vertical" style={{ height: "100%" }} />
</Col>
<Col span={11}>CONTENT OTHER SIDE</Col>
</Row>
https://codesandbox.io/s/antd-create-react-app-forked-rzp10?file=/index.js:181-499

Semantic-UI-React: Card header with 2 columns

I want the card header to be the normal text together with an image, side by side.
import logo from './images/logo.svg';
render() {
return (
<div>
<Card>
<Card.Content className='left aligned'>
<div className="two column headers">
<Card.Header>Hello World!</Card.Header>
<Image src={logo} size='tiny'/>
</div>
<Card.Meta>Item</Card.Meta>
<Card.Meta>Category</Card.Meta>
</Card.Content>
<Card.Content>
<Card.Description>10 units of test.</Card.Description>
</Card.Content>
</Card>
</div>
);
The image is appearing just after the 'Hello World!' header. How can I put them side by side, left aliging the text and right aligning the image ?
You can do this with CSS, however I will recomend to use Grid there.
<Card.Header>
<Grid>
<Grid.Column width={12}>Hello World!</Grid.Column>
<Grid.Column width={4}>
<Image src={logo} size='tiny'/>
</Grid.Column>
</Grid>
</Card.Header>
By the way, if you want to have an Image component on left, you can use Header component, see examples.

Categories

Resources