Introducing ReUI:Open-source UI components and apps built with React, Next.js and Tailwind CSS
Browse ReUI

Angular Tiny Slider


Hi, I would like to create a page that uses the Tiny Slider in Angular but I have not been able to find any reusable code. Has anyone already implemented this who is prepared to share example code?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


Perhaps you could take a look at this page for reference Chill Guy Clicker



# **Tiny Slider Integration in Angular**

## **1. Install Tiny Slider**
Run the following command to install Tiny Slider:
```
npm install tiny-slider --save
```

## **2. Create a Reusable Angular Component**
Generate a new component:
```
ng generate component tiny-slider
```

## **3. Modify `tiny-slider.component.ts`**
```typescript
import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core';
import { tns } from 'tiny-slider/src/tiny-slider';

@Component({
selector: 'app-tiny-slider',
templateUrl: './tiny-slider.component.html',
styleUrls: ['./tiny-slider.component.css']
})
export class TinySliderComponent implements AfterViewInit {
@ViewChild('slider', { static: false }) slider!: ElementRef;
@Input() options: any;

ngAfterViewInit() {
tns({
container: this.slider.nativeElement,
items: 1,
slideBy: 'page',
autoplay: true,
...this.options
});
}
}
```

## **4. Modify `tiny-slider.component.html`**
```html
<div #slider class="my-slider">
<ng-content></ng-content>
</div>
```

## **5. Modify `tiny-slider.component.css`**
```css
.my-slider {
display: flex;
overflow: hidden;
}

.my-slider img {
width: 100%;
}
```

## **6. Use the Component in Another Component**
```html
<app-tiny-slider [options]="sliderOptions">
<div><img src="https://via.placeholder.com/800x400/ff7f7f/333333?text=Slide+1" alt="Slide 1"></div>
<div><img src="https://via.placeholder.com/800x400/7f7fff/333333?text=Slide+2" alt="Slide 2"></div>
<div><img src="https://via.placeholder.com/800x400/7fff7f/333333?text=Slide+3" alt="Slide 3"></div>
</app-tiny-slider>
```

## **7. Define Options in the Parent Component**
```typescript
sliderOptions = {
items: 1,
autoplay: true,
controls: false,
nav: true
};
```

## **Why Use This Approach**
- **Reusable**: You can use `<app-tiny-slider>` anywhere.
- **Customizable**: Pass different options via `[options]`.
- **Encapsulated**: Styles and logic are contained within the component.

```
Play <a href="https://driftboss.site/" rel='dofllow'>drift boss</a>
<a href="https://eggy-car.site/" rel='dofllow'>Play Eggy Car</a>



Step 1: Install Tiny Slider
First, you need to install the Tiny Slider package. You can do this using npm:

npm install tiny-slider --save

Step 2: Create a Reusable Component
Create a new component for the slider. You can name it tiny-slider.
ng generate component tiny-slider
Step 3: Implement the Tiny Slider Component
In the tiny-slider.component.ts, import Tiny Slider and set it up:


import { Component, AfterViewInit, Input } from '@angular/core';
import { tns } from 'tiny-slider';

@Component({
selector: 'app-tiny-slider',
templateUrl: './tiny-slider.component.html',
styleUrls: ['./tiny-slider.component.css']
})
export class TinySliderComponent implements AfterViewInit {
@Input() items: string[] = [];

ngAfterViewInit() {
tns({
container: '.my-slider',
items: 1,
slideBy: 'page',
autoplay: true,
nav: true,
controls: true,
responsive: {
640: {
items: 1
},
768: {
items: 2
},
900: {
items: 3
}
}
});
}
}
Step 4: Create the Template
In the tiny-slider.component.html, set up the HTML structure for the slider:
<div class="my-slider">
<div *ngFor="let item of items" class="my-slider-item">
<img [src]="item" alt="Slider Image" />
</div>
</div>
Step 5: Add Styles
In the tiny-slider.component.css, you can add some basic styles for the slider:
.my-slider {
margin: 0 auto;
}

.my-slider-item {
text-align: center;
}

.my-slider-item img {
width: 100%;
border-radius: 8px;
}

Step 6: Use the Component
Now, you can use the TinySliderComponent in any of your Angular components. For example, in app.component.ts:
import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
images = [
'https://via.placeholder.com/600x300?text=Image+1',
'https://via.placeholder.com/600x300?text=Image+2',
'https://via.placeholder.com/600x300?text=Image+3'
];
}

Step 7: Import Tiny Slider CSS
Finally, make sure to include Tiny Slider's CSS in your angular.json:
"styles": [
"src/styles.css",
"node_modules/tiny-slider/dist/tiny-slider.css"
],
@tap road



The platform is incredibly user-friendly, and it’s always a pleasure to log in and play. I found it through https://valorplay.in/ and loved how smooth the interface is. It makes exploring different games so easy, and I never run out of interesting slots to play. Perfect for anyone looking for a great time.



Hi Shane Fryer,

It seems we don’t have Tiny Slider implemented in the demo app. However, you can easily add it to your Angular project by installing it via npm.

Install using npm:

npm install tiny-slider --save


Import the Tiny Slider CSS file in your angular.json or SCSS file

@import "~tiny-slider/dist/tiny-slider.css";


Check here for more example:

https://github.com/ganlanyuan/tiny-slider


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(