Using OwlCarousel navigation to display cards with left and right controls in a React.js application

I am attempting to incorporate the use of owl-carousel. My goal is to display one item at a time and include next and previous buttons on the left and right sides of my cards. I'm unsure how to achieve this, so any assistance would be greatly appreciated.

I will provide the code I have tried in codesandbox

<OwlCarousel
  className="owl-theme"
  loop={true}
  nav={true}
  items={1}
  autoHeight={true}
>

Answer №1

For those interested, you may want to check out the alternative solution for positioning buttons in a non-react version of owlcarousel.

Include the navText

navText={[
  '<span class="arrow prev">‹</span>',
  '<span class="arrow next">›</span>'
]}

as well as the corresponding CSS

.arrow {
  position: absolute;
  border-radius: 3px;
  font-size: 26px;
  top: 50%;
}

.arrow:hover {
  background: #869791;
  color: #fff;
}

.next {
  right: 10px;
}

.prev {
  left: 10px;
}

https://codesandbox.io/s/cranky-surf-982xxs?file=/src/App.js

Please note that while this solution may work effectively overall, some users may not prefer it due to the static nature of the buttons at the bottom, with only the spans moving to the sides.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Use parameters with initialRouteName in React Native StackNavigator

When using the 'react-navigation' library, I am wondering how to pass parameters with the initialRouteName in Stack.Navigator. return ( <Stack.Navigator initialRouteName={routeName} screenOptions={{ animation: 'sl ...

What could be causing the partial failure of my CSS stylesheet in my Django application? Could it be related to retrieving data from the database?

After following various tutorials, including one on LinkedIn, I believe my Django settings are correct. However, I am facing an issue with the CSS stylesheet in my app. The styling works perfectly everywhere except for the section where I retrieve data fro ...

The col-md-4 class in Bootstrap does not consistently maintain a width of 33%

Currently, I am utilizing bootstrap cards in my project. The number of cards within a card-deck varies dynamically. However, I have encountered an issue where each card should occupy a width of col-md-4 (33%). Everything works fine when there are more than ...

React Native tutorial: Changing button color on press

When a user clicks on the TouchableOpacity element, I want to change the color of the button from the default gray to blue. Initially, the 'checked={this.state.newProjects}' newProjects variable is not present in the state, so when clicked it sho ...

Ways to display divs by moving the mouse across the entire screen, rather than just over the specific element

I successfully implemented functionality to hide and show my classes when the user hovers over a specific element. However, what I really want is for these classes to show up when the user moves their mouse anywhere on the screen, not limited to just the s ...

Error message: The 'target' property cannot be read because it is undefined - react

←→1 out of 3 errors found on the page Error: The property 'target' is undefined and cannot be read This error occurred in the following section: App.inputChangeHandler src/App.js:37 34 | 35 | inputChangeHandler(index,event){ 36 | ...

Dynamic styles object for React components with inline styles

I have a styles object let styles = { step_div:{ height:'150px', } } I'm trying to display multiple div elements with different colors using React class Layout extends React.Component{ constructor(props) { super(props); ...

Attempting to create a div element that automatically adjusts itself horizontally in the center through the utilization of margins

I searched through examples on stack overflow that had similar problems to mine, but unfortunately, I couldn't find a solution. I'm not sure what I'm doing wrong, but the div is not aligning horizontally center as expected. It seems to work ...

Unable to get create-react-library to function properly with styled components

Using create-react-library to develop my component library has been a smooth process overall. However, when attempting to integrate Styled Components, I encountered an unexpected React hooks error. If you're interested, take a look at the code here: ...

Tips for spinning HTML5 Canvas's background image and adjusting the zoom with a slider

As someone who is new to the world of coding, I have a few goals in mind: First and foremost, I want to create a canvas. I also aim to add a background image to the canvas. Importantly, this background image should be separate from any foreground images ...

What is the process for retrieving a single document from Firebase and how can the document's ID be passed for deletion?

My project involves React Native and Firebase, and I have encountered 2 questions: What is the recommended way to pass an ID from one CV to another? How can I retrieve only one specific CV from Firebase? When I attempt this, I receive the following e ...

Material-Table React with a Fixed Header

After examining this specific example, I have a query regarding a sticky header feature. Here is the example link: https://material-table.com/#/docs/features/fixed-columns I have been attempting to make the header from 'Name' to 'BirthPlace ...

Maintained grid column stability amidst various modifications

I have a complex 2-column grid layout, and the example shown here is just one part of it. The complete code follows a similar structure. I am looking for a way to ensure that the green box always stays close to the red box in the layout, without having a ...

Are there any resources available that list the various React features for client use?

As I prepare to upgrade to the next version of React (13), I am interested in utilizing React Server components. After reading through the documentation on use client, it was mentioned that use client is necessary for client-only React functionalities. I& ...

Collaborating an Ember JS application with a React host through microfrontend integration

While attempting to integrate various frontend technologies within a React host using microfrontends, I successfully connected React, Vue, and VanillaJS applications to the host. However, I've hit a roadblock when it comes to incorporating Ember JS. U ...

Having trouble getting the branding logo, icon, and hamburger menu button to line up properly on mobile devices

I'm relatively new to Bootstrap and still trying to wrap my head around it. My goal is to have the branding logo aligned to the left, with the phone icon and hamburger nav icon on the right. Here's an example of what I'm aiming for: https: ...

Concealing or revealing an image with jQuery when hovering

I currently have 3 <a> tags within my html, each containing 2 images. Specifically, the greyscale images are the ones that are visible while the colored ones are set to display:none. I am aiming to achieve a functionality where upon hovering over th ...

Tips for keeping Appbar content from stretching to the edges of larger displays

I am trying to find a way to center the content of my Appbar, preventing it from spreading to the sides of the screen on larger displays. Check out these images for reference. The issue I'm facing is that on smaller screens, both the Appbar and page ...

The ReactDom reference is not defined when working with React and webpack

After following a tutorial on React and webpack from jslog.com, I encountered issues with using updated syntax such as using ReactDom to call render instead of the deprecated 'React.renderComponent'. I tried running: npm install --save react-do ...

Abstract forms on the canvas are dancing in a strange and unusual rhythm

As a beginner in web design, I've made progress but still have questions. Can someone help explain this to me? Here is how a specific section on my website is set up: https://i.sstatic.net/8ntpR.png I'm working on splitting the screen with 40% ...